diff --git a/src/jdrafting/geom/JDMath.java b/src/jdrafting/geom/JDMath.java index 7bf857e..edee2fa 100644 --- a/src/jdrafting/geom/JDMath.java +++ b/src/jdrafting/geom/JDMath.java @@ -8,6 +8,8 @@ import java.awt.geom.Line2D; import java.awt.geom.PathIterator; import java.awt.geom.Point2D; +import java.util.LinkedList; +import java.util.List; /** * Math utility operations @@ -191,6 +193,86 @@ public static double projection( Point2D v, Point2D w ) return abs( scalar( v, w ) / v.distance( 0, 0 ) ); } + /** + * Get incenter of a triangle + * @param a vertex + * @param b vertex + * @param c vertex + * @return the incenter + */ + public static Point2D incenter( Point2D A, Point2D B, Point2D C ) + { + double a = vector( B, C ).distance( 0, 0 ); + double b = vector( A, C ).distance( 0, 0 ); + double c = vector( A, B ).distance( 0, 0 ); + double abc = a + b + c; + + return new Point2D.Double( + ( a * A.getX() + b * B.getX() + c * C.getX() ) / abc, + ( a * A.getY() + b * B.getY() + c * C.getY() ) / abc ); + } + + /** + * Get ortocenter of a triangle + * @param A vertex + * @param B vertex + * @param C vertex + * @return the ortocenter or null if vertex are aligned + */ + public static Point2D ortocenter( Point2D A, Point2D B, Point2D C ) + { + Point2D vBC = vector( B, C ); + Point2D nBC = normal( vBC ); + Point2D vAC = vector( A, C ); + Point2D nAC = normal( vAC ); + + return linesIntersection( A, sumVectors( A, nBC ), + B, sumVectors( B, nAC ) ); + } + + /** + * Get baricenter of a triangle + * @param a vertex + * @param b vertex + * @param c vertex + * @return the baricenter + */ + public static Point2D baricenter( Point2D A, Point2D B, Point2D C ) + { + List vertex = new LinkedList<>(); + vertex.add( A ); + vertex.add( B ); + vertex.add( C ); + + return centroid( vertex ); + } + + /** + * Get circumcenter of a triangle + * @param a vertex + * @param b vertex + * @param c vertex + * @return the circumcenter + */ + public static Point2D circumcenter( Point2D A, Point2D B, Point2D C ) + { + double Ax = A.getX(), Ay = A.getY(); + double Bx = B.getX(), By = B.getY(); + double Cx = C.getX(), Cy = C.getY(); + double dCBx = Cx - Bx, dBCy = By - Cy; + double dACx = Ax - Cx, dCAy = Cy - Ay; + double dBAx = Bx - Ax, dABy = Ay - By; + double d = 2 * ( Ax * dBCy + Bx * dCAy + Cx * dABy ); + + return new Point2D.Double( + ( ( Ax * Ax + Ay * Ay ) * dBCy + + ( Bx * Bx + By * By ) * dCAy + + ( Cx * Cx + Cy * Cy ) * dABy ) / d, + ( ( Ax * Ax + Ay * Ay ) * dCBx + + ( Bx * Bx + By * By ) * dACx + + ( Cx * Cx + Cy * Cy ) * dBAx ) / d ); + } + /** * Shape length (poligonal length) * @param shape the shape diff --git a/src/jdrafting/gui/Application.java b/src/jdrafting/gui/Application.java index 6e04516..96b3242 100644 --- a/src/jdrafting/gui/Application.java +++ b/src/jdrafting/gui/Application.java @@ -1,11 +1,13 @@ package jdrafting.gui; +import static jdrafting.gui.JDUtils.getLargeIcon; import static jdrafting.gui.JDUtils.getLocaleText; import static jdrafting.gui.JDUtils.getSmallIcon; import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Container; import java.awt.Desktop; import java.awt.Dimension; @@ -52,6 +54,7 @@ import javax.swing.JMenuBar; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.JPopupMenu; import javax.swing.JRadioButtonMenuItem; import javax.swing.JScrollPane; import javax.swing.JSpinner; @@ -136,11 +139,14 @@ import jdrafting.gui.controller.actions.SplineAction; import jdrafting.gui.controller.actions.TextVisibleAction; import jdrafting.gui.controller.actions.TranslationAction; +import jdrafting.gui.controller.actions.TriangleAction; +import jdrafting.gui.controller.actions.TrianglePointsAction; import jdrafting.gui.controller.actions.UndoAction; import jdrafting.gui.controller.actions.VertexAction; import jdrafting.gui.controller.actions.ZoomAllAction; import jdrafting.gui.controller.actions.ZoomInOutAction; import jdrafting.gui.controller.mouse.HandListener; +import jdrafting.gui.controller.mouse.TrianglePointsListener; /** * GUI frame class @@ -154,7 +160,7 @@ public class Application extends JFrame ////////////////////// // metainfo public static final String APPNAME = "JDrafting"; - public static final String VERSION = "0.1.7.1"; // Some minor fixes + public static final String VERSION = "0.1.8"; public static final String AUTHOR = "Miguel Alejandro Moreno Barrientos"; public static final String COPYLEFT = "2016"; public static final String PROJECT_PAGE = @@ -211,6 +217,7 @@ public class Application extends JFrame public JMenu menuExercise; public JMenu menuTools; public JMenu menuTransform; + public JMenu menuTrianglePoints; public JMenu menuView; public JMenu menuAppearance; public JMenu menuHelp; @@ -220,6 +227,7 @@ public class Application extends JFrame public JButton buttonColor, buttonPointColor; public JButton buttonRuler, buttonProtactor; public JCheckBox checkRuler; + public JButton buttonMultiplier; public JComboBox comboLineStyle; public JToggleButton toggleNames; public JLabel labelStatus; @@ -457,6 +465,26 @@ protected void paintComponent( Graphics g ) { checkRuler.setMinimumSize( checkRuler.getPreferredSize() ); checkRuler.addActionListener( evt -> setUseDistance( checkRuler.isSelected() ) ); + // multiplier button + rulerProtToolbar.add( buttonMultiplier = + new JButton( "xN" ) ); + buttonMultiplier.setMaximumSize( buttonMultiplier.getPreferredSize() ); + buttonMultiplier.addActionListener( evt -> { + String result = (String) JOptionPane.showInputDialog( + this, getLocaleText( "dist_mult_dlg" ), "xN", + JOptionPane.QUESTION_MESSAGE, + getLargeIcon( "ruler.png" ), null, "1" ); + if ( result == null ) return; + try + { + setDistance( getDistance() * Double.valueOf( result ) ); + } + catch ( NumberFormatException e ) + { + JOptionPane.showMessageDialog( + this, e, "xN", JOptionPane.ERROR_MESSAGE ); + } + } ); rulerProtToolbar.add( Box.createHorizontalStrut( 12 ) ); // protractor button rulerProtToolbar.add( buttonProtactor = new JButton() ); @@ -715,6 +743,25 @@ public void actionPerformed(ActionEvent e) menuShapes.add( action = new AngleAction( this ) ); actionMap.put( action.getValue( Action.NAME ), action ); menuShapes.addSeparator(); + // Triangle notable points tool + menuShapes.add( menuTrianglePoints = new JMenu() ); + menuTrianglePoints.setText( getLocaleText( "triangle_tools" ) ); + menuTrianglePoints.setIcon( getSmallIcon( "triangle_popup.png" ) ); + menuTrianglePoints.add( action = new TriangleAction( this ) ); + actionMap.put( action.getValue( Action.NAME ), action ); + menuTrianglePoints.addSeparator(); + menuTrianglePoints.add( action = new TrianglePointsAction( + this, TrianglePointsListener.BARICENTER ) ); + actionMap.put( action.getValue( Action.NAME ), action ); + menuTrianglePoints.add( action = new TrianglePointsAction( + this, TrianglePointsListener.CIRCUMCENTER ) ); + actionMap.put( action.getValue( Action.NAME ), action ); + menuTrianglePoints.add( action = new TrianglePointsAction( + this, TrianglePointsListener.INCENTER ) ); + actionMap.put( action.getValue( Action.NAME ), action ); + menuTrianglePoints.add( action = new TrianglePointsAction( + this, TrianglePointsListener.ORTOCENTER ) ); + actionMap.put( action.getValue( Action.NAME ), action ); // Rectangle shape menuShapes.add( action = new RectangleAction( this ) ); actionMap.put( action.getValue( Action.NAME ), action ); @@ -943,7 +990,6 @@ public void actionPerformed(ActionEvent arg0) actionMap.put( action.getValue( Action.NAME ), action ); // --- TOOLBARS ACTIONS - // actionbar actionbar.add( actionMap.get( getLocaleText( "new" ) ) ); actionbar.add( actionMap.get( getLocaleText( "open" ) ) ); actionbar.add( actionMap.get( getLocaleText( "save" ) ) ); @@ -1000,6 +1046,24 @@ public void actionPerformed(ActionEvent arg0) shapebar.add( actionMap.get( getLocaleText( "circumference" ) ) ); shapebar.add( actionMap.get( getLocaleText( "angle" ) ) ); shapebar.addSeparator( VSEP ); + JButton trianglePopup = new JButton( new AbstractAction() { + @Override + public void actionPerformed( ActionEvent e ) + { + Component src = (Component) e.getSource(); + JPopupMenu popup = new JPopupMenu(); + popup.add( actionMap.get( getLocaleText( "triangle" ) ) ); + popup.addSeparator(); + popup.add( actionMap.get( getLocaleText( "baricenter" ) ) ); + popup.add( actionMap.get( getLocaleText( "ortocenter" ) ) ); + popup.add( actionMap.get( getLocaleText( "circumcenter" ) ) ); + popup.add( actionMap.get( getLocaleText( "incenter" ) ) ); + popup.show( src, (int) src.getBounds().getWidth() - 4, -2 ); + } + }); + trianglePopup.setToolTipText( getLocaleText( "triangle_tools" ) ); + trianglePopup.setIcon( getLargeIcon( "triangle_popup.png" ) ); + shapebar.add( trianglePopup ); shapebar.add( actionMap.get( getLocaleText( "rectangle" ) ) ); shapebar.add( actionMap.get( getLocaleText( "ellipse" ) ) ); shapebar.add( actionMap.get( getLocaleText( "polygon" ) ) ); @@ -1021,6 +1085,7 @@ public void actionPerformed(ActionEvent arg0) toolbar.add( actionMap.get( getLocaleText( "vertex" ) ) ); toolbar.add( actionMap.get( getLocaleText( "extremes" ) ) ); toolbar.add( actionMap.get( getLocaleText( "divisions" ) ) ); + toolbar.add( actionMap.get( "Triangle points" ) ); toolbar.add( actionMap.get( getLocaleText( "inter" ) ) ); toolbar.add( actionMap.get( getLocaleText( "bounds" ) ) ); toolbar.addSeparator( HSEP ); diff --git a/src/jdrafting/gui/controller/actions/ActionTrianglePoints.java b/src/jdrafting/gui/controller/actions/ActionTrianglePoints.java new file mode 100644 index 0000000..481a94f --- /dev/null +++ b/src/jdrafting/gui/controller/actions/ActionTrianglePoints.java @@ -0,0 +1,41 @@ +package jdrafting.gui.controller.actions; + +import static jdrafting.gui.JDUtils.getLargeIcon; +import static jdrafting.gui.JDUtils.getLocaleText; +import static jdrafting.gui.JDUtils.getSmallIcon; + +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +import javax.swing.AbstractAction; +import javax.swing.KeyStroke; + +import jdrafting.gui.Application; +import jdrafting.gui.controller.mouse.AngleListener; + +@SuppressWarnings("serial") +public class ActionTrianglePoints extends AbstractAction +{ + private Application app; + + public ActionTrianglePoints( Application app ) + { + this.app = app; + + putValue( NAME, getLocaleText( "angle" ) ); + putValue( SHORT_DESCRIPTION, getLocaleText( "angle_des" ) ); + putValue( MNEMONIC_KEY, KeyEvent.VK_N ); + putValue( ACCELERATOR_KEY, + KeyStroke.getKeyStroke( KeyEvent.VK_6, InputEvent.CTRL_MASK ) ); + putValue( SMALL_ICON, getSmallIcon( "angle.png" ) ); + putValue( LARGE_ICON_KEY, getLargeIcon( "angle.png" ) ); + } + + @Override + public void actionPerformed(ActionEvent e) + { + app.getCanvas().setCanvasListener( + new AngleListener( app.getCanvas() ) ); + } +} diff --git a/src/jdrafting/gui/controller/actions/TriangleAction.java b/src/jdrafting/gui/controller/actions/TriangleAction.java new file mode 100644 index 0000000..11a46d3 --- /dev/null +++ b/src/jdrafting/gui/controller/actions/TriangleAction.java @@ -0,0 +1,38 @@ +package jdrafting.gui.controller.actions; + +import static jdrafting.gui.JDUtils.getLargeIcon; +import static jdrafting.gui.JDUtils.getLocaleText; + +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; + +import javax.swing.AbstractAction; + +import jdrafting.gui.Application; +import jdrafting.gui.controller.mouse.TriangleListener; + +@SuppressWarnings("serial") +public class TriangleAction extends AbstractAction +{ + private Application app; + + public TriangleAction( Application app ) + { + this.app = app; + + putValue( NAME, getLocaleText( "triangle" ) ); + putValue( SHORT_DESCRIPTION, getLocaleText( "triangle_des" ) ); + putValue( MNEMONIC_KEY, KeyEvent.VK_T ); + /*putValue( ACCELERATOR_KEY, + KeyStroke.getKeyStroke( KeyEvent.VK_5, InputEvent.CTRL_MASK ) );*/ + putValue( SMALL_ICON, getLargeIcon( "triangle.png" ) ); + putValue( LARGE_ICON_KEY, getLargeIcon( "triangle.png" ) ); + } + + @Override + public void actionPerformed(ActionEvent e) + { + app.getCanvas().setCanvasListener( + new TriangleListener( app.getCanvas() ) ); + } +} diff --git a/src/jdrafting/gui/controller/actions/TrianglePointsAction.java b/src/jdrafting/gui/controller/actions/TrianglePointsAction.java new file mode 100644 index 0000000..27b6606 --- /dev/null +++ b/src/jdrafting/gui/controller/actions/TrianglePointsAction.java @@ -0,0 +1,51 @@ +package jdrafting.gui.controller.actions; + +import static jdrafting.gui.JDUtils.getLargeIcon; + +import java.awt.event.ActionEvent; + +import javax.swing.AbstractAction; +import javax.swing.ImageIcon; + +import jdrafting.gui.Application; +import jdrafting.gui.controller.mouse.TrianglePointsListener; + +@SuppressWarnings("serial") +public class TrianglePointsAction extends AbstractAction +{ + private Application app; + private int type; + + public TrianglePointsAction( Application app, int type ) + { + this.app = app; + this.type = type; + + putValue( NAME, TrianglePointsListener.getName( type ) ); + ImageIcon large = null; + switch( type ) + { + case TrianglePointsListener.INCENTER: + large = getLargeIcon( "incenter.png" ); + break; + case TrianglePointsListener.BARICENTER: + large = getLargeIcon( "baricenter.png" ); + break; + case TrianglePointsListener.CIRCUMCENTER: + large = getLargeIcon( "circumcenter.png" ); + break; + case TrianglePointsListener.ORTOCENTER: + large = getLargeIcon( "ortocenter.png" ); + break; + } + putValue( SMALL_ICON, large ); + putValue( LARGE_ICON_KEY, large ); + } + + @Override + public void actionPerformed( ActionEvent e ) + { + app.getCanvas().setCanvasListener( + new TrianglePointsListener( app.getCanvas(), type ) ); + } +} diff --git a/src/jdrafting/gui/controller/mouse/BisectrixListener.java b/src/jdrafting/gui/controller/mouse/BisectrixListener.java index 82aa262..ca091e0 100644 --- a/src/jdrafting/gui/controller/mouse/BisectrixListener.java +++ b/src/jdrafting/gui/controller/mouse/BisectrixListener.java @@ -135,7 +135,7 @@ else if ( bis1 == null ) } canvas.repaint(); } - + @Override public void paintTool( Graphics2D g2 ) { diff --git a/src/jdrafting/gui/controller/mouse/TriangleListener.java b/src/jdrafting/gui/controller/mouse/TriangleListener.java new file mode 100644 index 0000000..abceab6 --- /dev/null +++ b/src/jdrafting/gui/controller/mouse/TriangleListener.java @@ -0,0 +1,118 @@ +package jdrafting.gui.controller.mouse; + +import static jdrafting.gui.JDUtils.getLocaleText; + +import java.awt.BasicStroke; +import java.awt.Cursor; +import java.awt.Graphics2D; +import java.awt.event.MouseEvent; +import java.awt.geom.AffineTransform; +import java.awt.geom.Line2D; +import java.awt.geom.Path2D; +import java.awt.geom.Point2D; + +import jdrafting.gui.Application; +import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; + +/** + * Create triangle using mouse control + */ +public class TriangleListener extends AbstractCanvasMouseListener +{ + private static final Cursor CURSOR = + JDUtils.getCustomCursor( "triangle_cursor.png" ); + private CanvasPanel canvas; + private Application app; + + private Point2D A, B; + + public TriangleListener( CanvasPanel canvas ) + { + super( canvas ); + + this.canvas = canvas; + app = canvas.getApplication(); + + canvas.setCursor( CURSOR ); + + app.setStatusText( getLocaleText( "txt_triangle_points1" ) ); + } + + @Override + public void mouseMoved( MouseEvent e ) + { + super.mouseMoved( e ); + + if ( A != null ) + canvas.repaint(); + } + + @Override + public void mouseReleased( MouseEvent e ) + { + super.mouseReleased( e ); + + // mouse position in logic viewport + Point2D logicMouse = canvas.adjustToPoint( e.getPoint() ); + + // first vertex + if ( A == null ) + A = logicMouse; + // second vertex + else if ( B == null ) + B = logicMouse; + else + { + // create triangle + Path2D triangle = new Path2D.Double(); + triangle.moveTo( A.getX(), A.getY() ); + triangle.lineTo( B.getX(), B.getY() ); + triangle.lineTo( logicMouse.getX(), logicMouse.getY() ); + triangle.lineTo( A.getX(), A.getY() ); + + // add triangle to exercise + app.addShapeFromIterator( triangle.getPathIterator( null ), + "", "", app.getColor(), app.getStroke() ); + + // back to select mode + canvas.setCanvasListener( new HandListener( canvas ) ); + } + } + + @Override + public void paintTool( Graphics2D g2 ) + { + if ( A == null ) return; + + AffineTransform transform = canvas.getTransform(); + + // mouse position on logic viewport + Point2D logicMouse = canvas.adjustToPoint( mouse().getPoint() ); + + // set tool style + g2.setColor( Application.TOOL_MAIN_COLOR ); + g2.setStroke( new BasicStroke( 1f ) ); + + // draw triangle + if ( B == null ) + { + g2.draw( transform.createTransformedShape( + new Line2D.Double( A, logicMouse ) ) ); + return; + } + else + g2.draw( transform.createTransformedShape( + new Line2D.Double( A, B ) ) ); + g2.draw( transform.createTransformedShape( + new Line2D.Double( A, logicMouse ) ) ); + g2.draw( transform.createTransformedShape( + new Line2D.Double( B, logicMouse ) ) ); + } + + // --- HELPERS + + // check modifiers + /*private boolean isRectangle() { return mouse().isControlDown(); } + private boolean isEquilateral() { return mouse().isShiftDown(); }*/ +} diff --git a/src/jdrafting/gui/controller/mouse/TrianglePointsListener.java b/src/jdrafting/gui/controller/mouse/TrianglePointsListener.java new file mode 100644 index 0000000..42040ec --- /dev/null +++ b/src/jdrafting/gui/controller/mouse/TrianglePointsListener.java @@ -0,0 +1,190 @@ +package jdrafting.gui.controller.mouse; + +import static jdrafting.geom.JDMath.baricenter; +import static jdrafting.geom.JDMath.circumcenter; +import static jdrafting.geom.JDMath.incenter; +import static jdrafting.geom.JDMath.ortocenter; +import static jdrafting.gui.JDUtils.getLocaleText; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Graphics2D; +import java.awt.event.MouseEvent; +import java.awt.geom.AffineTransform; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JOptionPane; + +import jdrafting.geom.JDPoint; +import jdrafting.gui.Application; +import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; + +/** + * Create bari/orto/circum/in-center using mouse control + */ +public class TrianglePointsListener extends AbstractCanvasMouseListener +{ + private static final Map CURSOR; + public static final int BARICENTER = 0; + public static final int INCENTER = 1; + public static final int CIRCUMCENTER = 2; + public static final int ORTOCENTER = 3; + private CanvasPanel canvas; + private Application app; + + private int type; + private Point2D A, B; + + static { + CURSOR = new HashMap<>(); + CURSOR.put( BARICENTER, + JDUtils.getCustomCursor( "baricenter_cursor.png" ) ); + CURSOR.put( INCENTER, + JDUtils.getCustomCursor( "incenter_cursor.png" ) ); + CURSOR.put( CIRCUMCENTER, + JDUtils.getCustomCursor( "circumcenter_cursor.png" ) ); + CURSOR.put( ORTOCENTER, + JDUtils.getCustomCursor( "ortocenter_cursor.png" ) ); + } + + public TrianglePointsListener( CanvasPanel canvas, int type ) + { + super( canvas ); + + this.canvas = canvas; + app = canvas.getApplication(); + this.type = type; + + canvas.setCursor( CURSOR.get( type ) ); + + app.setStatusText( getLocaleText( "txt_triangle_points1" ) ); + } + + @Override + public void mouseMoved( MouseEvent e ) + { + super.mouseMoved( e ); + + if ( A != null ) + canvas.repaint(); + } + + @Override + public void mouseReleased( MouseEvent e ) + { + super.mouseReleased( e ); + + // mouse position in logic viewport + Point2D logicMouse = canvas.adjustToPoint( e.getPoint() ); + + if ( A == null ) + A = logicMouse; + else if ( B == null ) + B = logicMouse; + else + { + Point2D point = getPoint( logicMouse ); + if ( point == null ) + JOptionPane.showMessageDialog( app, "null point", + "Error in triangle", JOptionPane.ERROR_MESSAGE ); + else + { + Color color = e.isShiftDown() + ? app.getColor() + : app.getPointColor(); + BasicStroke stroke = e.isShiftDown() + ? app.getStroke() + : app.getPointStroke(); + app.addShapeFromIterator( + new JDPoint( point ).getPathIterator( null ), "", + "> " + getName( type ), color, stroke ); + } + + // back to select mode + canvas.setCanvasListener( new HandListener( canvas ) ); + } + } + + @Override + public void paintTool( Graphics2D g2 ) + { + if ( A == null ) return; + + AffineTransform transform = canvas.getTransform(); + + // mouse position on logic viewport + Point2D logicMouse = canvas.adjustToPoint( mouse().getPoint() ); + + g2.setColor( Application.TOOL_MAIN_COLOR ); + g2.setStroke( new BasicStroke( 1f ) ); + + if ( B == null ) + { + g2.draw( transform.createTransformedShape( + new Line2D.Double( A, logicMouse ) ) ); + return; + } + else + g2.draw( transform.createTransformedShape( + new Line2D.Double( A, B ) ) ); + g2.draw( transform.createTransformedShape( + new Line2D.Double( A, logicMouse ) ) ); + g2.draw( transform.createTransformedShape( + new Line2D.Double( B, logicMouse ) ) ); + + // draw temporary triangle point + Point2D point = getPoint( logicMouse ); + if ( point != null ) + { + transform.transform( point, point ); + g2.fill( new Ellipse2D.Double( + point.getX() - 4, point.getY() - 4, 8, 8 ) ); + } + } + + // --- HELPERS --- + + /** + * Get action triangle point + * @param logicMouse mouse logic position + * @return the suitable point + */ + private Point2D getPoint( Point2D logicMouse ) + { + switch( type ) + { + case INCENTER: return incenter( A, B, logicMouse ); + case ORTOCENTER: return ortocenter( A, B, logicMouse ); + case BARICENTER: return baricenter( A, B, logicMouse ); + case CIRCUMCENTER: return circumcenter( A, B, logicMouse ); + default: return null; + } + } + + /** + * Get action name + * @param type point type (defined constants) + * @return an action string name in locale lenguage + */ + public static String getName( int type ) + { + switch ( type ) + { + case TrianglePointsListener.INCENTER: + return getLocaleText( "incenter" ); + case TrianglePointsListener.ORTOCENTER: + return getLocaleText( "ortocenter" ); + case TrianglePointsListener.CIRCUMCENTER: + return getLocaleText( "circumcenter" ); + case TrianglePointsListener.BARICENTER: + return getLocaleText( "baricenter" ); + default: return "Triangle notable points"; + } + } +} diff --git a/src/jdrafting/resources/images/baricenter.png b/src/jdrafting/resources/images/baricenter.png new file mode 100644 index 0000000..3f797bf Binary files /dev/null and b/src/jdrafting/resources/images/baricenter.png differ diff --git a/src/jdrafting/resources/images/circumcenter.png b/src/jdrafting/resources/images/circumcenter.png new file mode 100644 index 0000000..ff6382e Binary files /dev/null and b/src/jdrafting/resources/images/circumcenter.png differ diff --git a/src/jdrafting/resources/images/cursors/baricenter_cursor.png b/src/jdrafting/resources/images/cursors/baricenter_cursor.png new file mode 100644 index 0000000..56674a3 Binary files /dev/null and b/src/jdrafting/resources/images/cursors/baricenter_cursor.png differ diff --git a/src/jdrafting/resources/images/cursors/circumcenter_cursor.png b/src/jdrafting/resources/images/cursors/circumcenter_cursor.png new file mode 100644 index 0000000..861207d Binary files /dev/null and b/src/jdrafting/resources/images/cursors/circumcenter_cursor.png differ diff --git a/src/jdrafting/resources/images/cursors/incenter_cursor.png b/src/jdrafting/resources/images/cursors/incenter_cursor.png new file mode 100644 index 0000000..abd59b0 Binary files /dev/null and b/src/jdrafting/resources/images/cursors/incenter_cursor.png differ diff --git a/src/jdrafting/resources/images/cursors/ortocenter_cursor.png b/src/jdrafting/resources/images/cursors/ortocenter_cursor.png new file mode 100644 index 0000000..6d361a3 Binary files /dev/null and b/src/jdrafting/resources/images/cursors/ortocenter_cursor.png differ diff --git a/src/jdrafting/resources/images/cursors/triangle_cursor.png b/src/jdrafting/resources/images/cursors/triangle_cursor.png new file mode 100644 index 0000000..f5c8e0a Binary files /dev/null and b/src/jdrafting/resources/images/cursors/triangle_cursor.png differ diff --git a/src/jdrafting/resources/images/incenter.png b/src/jdrafting/resources/images/incenter.png new file mode 100644 index 0000000..325ca96 Binary files /dev/null and b/src/jdrafting/resources/images/incenter.png differ diff --git a/src/jdrafting/resources/images/ortocenter.png b/src/jdrafting/resources/images/ortocenter.png new file mode 100644 index 0000000..6b595cd Binary files /dev/null and b/src/jdrafting/resources/images/ortocenter.png differ diff --git a/src/jdrafting/resources/images/triangle.png b/src/jdrafting/resources/images/triangle.png new file mode 100644 index 0000000..b6980e7 Binary files /dev/null and b/src/jdrafting/resources/images/triangle.png differ diff --git a/src/jdrafting/resources/images/triangle_popup.png b/src/jdrafting/resources/images/triangle_popup.png new file mode 100644 index 0000000..07a680b Binary files /dev/null and b/src/jdrafting/resources/images/triangle_popup.png differ diff --git a/src/jdrafting/resources/language/language.properties b/src/jdrafting/resources/language/language.properties index a9ec999..e637d77 100644 --- a/src/jdrafting/resources/language/language.properties +++ b/src/jdrafting/resources/language/language.properties @@ -78,8 +78,6 @@ polygon=Polygon polygon_des=Create polygon polyline=Polyline polyline_des=Create polyline -spline=Spline -spline_des=Create spline between points free_hand=Free hand free_hand_des=Create an arbitrary shape rectangle=Rectangle @@ -92,6 +90,15 @@ circumference=Circumference circumference_des=Create circumference angle=Angle angle_des=Create a segment by angle +triangle_tools=Triangle tools +triangle=Triangle +triangle_des=Create triangle +incenter=Incenter +ortocenter=Ortocenter +baricenter=Baricenter +circumcenter=Circumcenter +spline=Spline +spline_des=Create spline between points ruler=Ruler ruler_des=Capture distance protractor=Protractor @@ -187,6 +194,7 @@ save_close=Save and Close details=Details selected_shapes_msg=You must select at least one shape homo_dlg=Homothety factor +dist_mult_dlg=Multiply distance by factor // new shapes default description new_midpoint=midpoint of @@ -264,3 +272,4 @@ txt_homothety1=Select homothety center. < txt_central_sym1=Select symmetry center txt_axial_sym1=Select first point of axis txt_axial_sym2=Select second point of axis +txt_triangle_points1=Select three point diff --git a/src/jdrafting/resources/language/language_en.properties b/src/jdrafting/resources/language/language_en.properties index a9ec999..e637d77 100644 --- a/src/jdrafting/resources/language/language_en.properties +++ b/src/jdrafting/resources/language/language_en.properties @@ -78,8 +78,6 @@ polygon=Polygon polygon_des=Create polygon polyline=Polyline polyline_des=Create polyline -spline=Spline -spline_des=Create spline between points free_hand=Free hand free_hand_des=Create an arbitrary shape rectangle=Rectangle @@ -92,6 +90,15 @@ circumference=Circumference circumference_des=Create circumference angle=Angle angle_des=Create a segment by angle +triangle_tools=Triangle tools +triangle=Triangle +triangle_des=Create triangle +incenter=Incenter +ortocenter=Ortocenter +baricenter=Baricenter +circumcenter=Circumcenter +spline=Spline +spline_des=Create spline between points ruler=Ruler ruler_des=Capture distance protractor=Protractor @@ -187,6 +194,7 @@ save_close=Save and Close details=Details selected_shapes_msg=You must select at least one shape homo_dlg=Homothety factor +dist_mult_dlg=Multiply distance by factor // new shapes default description new_midpoint=midpoint of @@ -264,3 +272,4 @@ txt_homothety1=Select homothety center. < txt_central_sym1=Select symmetry center txt_axial_sym1=Select first point of axis txt_axial_sym2=Select second point of axis +txt_triangle_points1=Select three point diff --git a/src/jdrafting/resources/language/language_es.properties b/src/jdrafting/resources/language/language_es.properties index 89d8e05..1123ef4 100644 --- a/src/jdrafting/resources/language/language_es.properties +++ b/src/jdrafting/resources/language/language_es.properties @@ -90,6 +90,13 @@ circumference=Circunferencia circumference_des=Crear circunferencia angle=Ángulo angle_des=Crear un segmento por ángulo +triangle_tools=Herramientas de triángulo +triangle=Triángulo +triangle_des=Crear triángulo +incenter=Incentro +ortocenter=Ortocentro +baricenter=Baricentro +circumcenter=Circuncentro spline=Spline spline_des=Crear spline entre puntos ruler=Regla @@ -187,6 +194,7 @@ save_close=Guardar y cerrar details=Detalles selected_shapes_msg=Se debe seleccionar al menos una figura homo_dlg=Factor de homotecia +dist_mult_dlg=Multiplicar distancia por factor // new shapes default description new_midpoint=punto medio de @@ -264,3 +272,4 @@ txt_homothety1=Seleccione centro de homoteciaSeleccione centro de simetría txt_axial_sym1=Seleccione primer punto del eje txt_axial_sym2=Seleccione segundo punto del eje +txt_triangle_points1=Seleccione tres puntos