diff --git a/lib/jme_3.3_lib.jar b/lib/jme_3.3_lib.jar deleted file mode 100644 index 362b8a1..0000000 Binary files a/lib/jme_3.3_lib.jar and /dev/null differ diff --git a/lib/jme_6_1.jar b/lib/jme_6_1.jar new file mode 100644 index 0000000..27691f5 Binary files /dev/null and b/lib/jme_6_1.jar differ diff --git a/src/jdrafting/geom/JDMath.java b/src/jdrafting/geom/JDMath.java index edee2fa..f4bffe0 100644 --- a/src/jdrafting/geom/JDMath.java +++ b/src/jdrafting/geom/JDMath.java @@ -195,9 +195,9 @@ public static double projection( Point2D v, Point2D w ) /** * Get incenter of a triangle - * @param a vertex - * @param b vertex - * @param c vertex + * @param A vertex + * @param B vertex + * @param C vertex * @return the incenter */ public static Point2D incenter( Point2D A, Point2D B, Point2D C ) diff --git a/src/jdrafting/geom/JDPoint.java b/src/jdrafting/geom/JDPoint.java index d515a78..0acf074 100644 --- a/src/jdrafting/geom/JDPoint.java +++ b/src/jdrafting/geom/JDPoint.java @@ -18,7 +18,6 @@ public Point2D.Double toPoint2Ddouble() @Override public Rectangle2D getBounds2D() { - return new Rectangle2D.Double( - getX1(), getY1(), Math.ulp( 0. ), Math.ulp( 0. ) ); + return new Rectangle2D.Double( getX1(), getY1(), Math.ulp( 0. ), Math.ulp( 0. ) ); } } diff --git a/src/jdrafting/gui/Application.java b/src/jdrafting/gui/Application.java index fe26389..50aa570 100644 --- a/src/jdrafting/gui/Application.java +++ b/src/jdrafting/gui/Application.java @@ -1,9 +1,9 @@ package jdrafting.gui; import static jdrafting.gui.JDUtils.getLargeIcon; +import static jdrafting.gui.JDUtils.getLocaleMnemonic; import static jdrafting.gui.JDUtils.getLocaleText; import static jdrafting.gui.JDUtils.getSmallIcon; -import static jdrafting.gui.JDUtils.getLocaleMnemonic; import java.awt.BasicStroke; import java.awt.BorderLayout; @@ -30,6 +30,7 @@ import java.io.ObjectInputStream; import java.net.URI; import java.net.URISyntaxException; +import java.util.Calendar; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -160,6 +161,7 @@ /** * {@value #APPNAME} GUI class * @author {@value #AUTHOR}, {@value #COPYLEFT} + * @since 0.1.0 * @version {@value #VERSION} */ @SuppressWarnings("serial") @@ -170,13 +172,13 @@ public class Application extends JFrame ////////////////////// // metainfo public static final String APPNAME = "JDrafting"; - public static final String VERSION = "0.1.9"; + public static final String VERSION = "0.1.10"; public static final String AUTHOR = "Miguel Alejandro Moreno Barrientos"; - public static final String COPYLEFT = "2016"; + public static final String COPYLEFT = "2016,2020"; public static final String PROJECT_PAGE = - "http://miguelalejandromorenobarrientos.github.io/jdrafting"; + "http://miguelalejandromorenobarrientos.github.io/jdrafting"; public static final String GITHUB_REPOSITORY = - "https://github.com/miguelalejandromorenobarrientos/jdrafting/tree/master"; + "https://github.com/miguelalejandromorenobarrientos/jdrafting/tree/master"; // colors public static Color toolMainColor = Color.BLUE; // separators @@ -188,9 +190,8 @@ public class Application extends JFrame // STATIC VARS // ///////////////// public static Locale locale = Locale.getDefault(); - public static String lookAndFeelClassName = - UIManager.getSystemLookAndFeelClassName(); - public static boolean jmeEnabled = false; + public static String lookAndFeelClassName = UIManager.getSystemLookAndFeelClassName(); + public static boolean jmeEnabled = true; /////////////////// @@ -210,7 +211,7 @@ public class Application extends JFrame private BasicStroke stroke = JDStrokes.PLAIN_ROUND.getStroke(); private Color pointColor = Color.DARK_GRAY; private BasicStroke pointStroke = - new BasicStroke( 8f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ); + new BasicStroke( 8f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ); // undo/redo public UndoManager undoManager; public UndoableEditSupport undoSupport; @@ -254,6 +255,11 @@ public class Application extends JFrame ///////////////// public Application() { + // easter egg joke + final int year = Calendar.getInstance().get( Calendar.YEAR ); + if ( year >= 2030 ) + System.out.println( "\n\tYeah! My program still running in " + year + "!!\n" ); + // create app window initUI(); createActions(); @@ -1168,7 +1174,7 @@ public void actionPerformed( ActionEvent e ) shapebar.add( actionMap.get( getLocaleText( "spline" ) ) ); shapebar.add( actionMap.get( getLocaleText( "free_hand" ) ) ); if ( jmeEnabled ) - shapebar.add( actionMap.get( "Math function" ) ); + shapebar.add( actionMap.get( getLocaleText( "func" ) ) ); // toolbar toolbar.add( actionMap.get( getLocaleText( "perp" ) ) ); toolbar.add( actionMap.get( getLocaleText( "para" ) ) ); @@ -1539,8 +1545,7 @@ public class EditAddShapeToExercise extends AbstractUndoableEdit private JDraftingShape jdshape; private int index; - public EditAddShapeToExercise(@NotNull JDraftingShape jdshape, - int index ) + public EditAddShapeToExercise( @NotNull JDraftingShape jdshape, int index ) { this.jdshape = jdshape; this.index = index; @@ -1633,8 +1638,7 @@ public static void main( String[] args ) // (some parameters like lang, lookfeel need to be executed // before app intantiation) JDraftingArgs argsParser = new JDraftingArgs( null ); - ParsedParameterMap parsedMap = - argsParser.parseAndExecute( args ); + ParsedParameterMap parsedMap = argsParser.parseAndExecute( args ); // application instance Application app = new Application(); @@ -1649,8 +1653,7 @@ public static void main( String[] args ) // load file from console // (file load must be executed with a visible app) if ( parsedMap.containsParam( "file" ) ) - app.openFile( - new File( parsedMap.getValues( "file" )[0] ) ); + app.openFile( new File( parsedMap.getValues( "file" )[0] ) ); } catch ( NoSuchElementException e ) { diff --git a/src/jdrafting/gui/CanvasPanel.java b/src/jdrafting/gui/CanvasPanel.java index 718b923..550b69e 100644 --- a/src/jdrafting/gui/CanvasPanel.java +++ b/src/jdrafting/gui/CanvasPanel.java @@ -170,6 +170,9 @@ public void paintComponent( Graphics g ) Graphics2D g2 = (Graphics2D) g; + // High quality render + JDUtils.setHighQualityRender( g2 ); + // draw exercise shapes drawExercise( g2, getTransform(), app.getExercise(), app.getSelectedShapes(), app.isVisibleNames() ); @@ -599,7 +602,8 @@ class MoveCanvasThread extends Thread public void stopMe() { stop = true; } @Override - public void run() { + public void run() + { while ( !stop ) { try { Thread.sleep( wait < MAX_WAIT ? 20 : 200 ); } diff --git a/src/jdrafting/gui/JDUtils.java b/src/jdrafting/gui/JDUtils.java index 0d9e289..7162b04 100644 --- a/src/jdrafting/gui/JDUtils.java +++ b/src/jdrafting/gui/JDUtils.java @@ -2,8 +2,10 @@ import java.awt.Cursor; import java.awt.Dimension; +import java.awt.Graphics2D; import java.awt.Image; import java.awt.Point; +import java.awt.RenderingHints; import java.awt.Toolkit; import java.awt.event.KeyEvent; import java.util.Locale; @@ -26,7 +28,7 @@ public class JDUtils private JDUtils() {} public static int smallIconSize = 16; - public static int largeIconSize = 32; + public static int largeIconSize = 24; /** * Get screen size, multiplied by factor @@ -146,4 +148,22 @@ public static String camelCase( String text ) return String.join( "", words ); } + + public static void setHighQualityRender( Graphics2D g2 ) + { + g2.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON ); + g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON ); + g2.setRenderingHint( RenderingHints.KEY_RENDERING, + RenderingHints.VALUE_RENDER_QUALITY ); + g2.setRenderingHint( RenderingHints.KEY_ALPHA_INTERPOLATION, + RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY ); + g2.setRenderingHint( RenderingHints.KEY_COLOR_RENDERING, + RenderingHints.VALUE_COLOR_RENDER_QUALITY ); + g2.setRenderingHint( RenderingHints.KEY_DITHERING, + RenderingHints.VALUE_DITHER_ENABLE ); + g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BILINEAR); + } } diff --git a/src/jdrafting/gui/ShapeList.java b/src/jdrafting/gui/ShapeList.java index c51a7ab..2e9aa66 100644 --- a/src/jdrafting/gui/ShapeList.java +++ b/src/jdrafting/gui/ShapeList.java @@ -113,8 +113,7 @@ public void valueChanged( ListSelectionEvent e ) /** * ListCellRenderer */ - class ShapeListRenderer extends JPanel implements - ListCellRenderer + class ShapeListRenderer extends JPanel implements ListCellRenderer { @Override public Component getListCellRendererComponent( @@ -140,6 +139,9 @@ protected void paintComponent( Graphics g ) super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; + + // High quality render + JDUtils.setHighQualityRender( g2 ); Viewport viewDest = new Viewport( 0, getWidth() - 1, 0, getHeight() - 1 ); @@ -168,10 +170,9 @@ protected void paintComponent( Graphics g ) mini.setMinimumSize( mini.getPreferredSize() ); // name add( Box.createHorizontalStrut( 4 ) ); - JLabel shapeName = new JLabel( - value.getName() != null && value.getName().length() > 0 - ? value.getName() - : "unnamed", JLabel.LEFT ); + JLabel shapeName = new JLabel( value.getName() != null && value.getName().length() > 0 + ? value.getName() + : "", JLabel.LEFT ); add( shapeName ); shapeName.setFont( new Font( Font.SANS_SERIF, Font.BOLD, 20 ) ); shapeName.setForeground( Color.BLUE ); diff --git a/src/jdrafting/gui/controller/actions/AboutAction.java b/src/jdrafting/gui/controller/actions/AboutAction.java index c7c1a63..a0a6851 100644 --- a/src/jdrafting/gui/controller/actions/AboutAction.java +++ b/src/jdrafting/gui/controller/actions/AboutAction.java @@ -13,7 +13,6 @@ import javax.swing.JEditorPane; import javax.swing.JOptionPane; import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; import jdrafting.gui.Application; import jdrafting.gui.JDUtils; @@ -68,24 +67,25 @@ public void actionPerformed( ActionEvent e ) + "CLA" + "

" + "

" - + "
@" + Application.COPYLEFT + + "Math parser for functions: " + + "" + + "JME parser" + + "

" + + "

" + + "
(C)" + Application.COPYLEFT + "

" + "" ); ep.setEditable( false ); ep.setOpaque( false ); - ep.addHyperlinkListener( new HyperlinkListener() { - @Override - public void hyperlinkUpdate( HyperlinkEvent e ) + ep.getCaret().deinstall( ep ); // non-selectable + ep.addHyperlinkListener( ev -> { + if ( ev.getEventType().equals( HyperlinkEvent.EventType.ACTIVATED ) + && Desktop.isDesktopSupported() + && Desktop.getDesktop().isSupported( Desktop.Action.BROWSE ) ) { - if ( e.getEventType().equals( - HyperlinkEvent.EventType.ACTIVATED ) - && Desktop.isDesktopSupported() - && Desktop.getDesktop().isSupported( - Desktop.Action.BROWSE ) ) - { - try { Desktop.getDesktop().browse( e.getURL().toURI() ); } - catch ( URISyntaxException | IOException ex ) {} - } + try { Desktop.getDesktop().browse( ev.getURL().toURI() ); } + catch ( URISyntaxException | IOException ex ) {} } }); JOptionPane.showMessageDialog( app, ep, "About " + Application.APPNAME, diff --git a/src/jdrafting/gui/controller/actions/ExtremesAction.java b/src/jdrafting/gui/controller/actions/ExtremesAction.java index b153fd3..bb53ccc 100644 --- a/src/jdrafting/gui/controller/actions/ExtremesAction.java +++ b/src/jdrafting/gui/controller/actions/ExtremesAction.java @@ -36,8 +36,7 @@ public ExtremesAction( Application app ) @Override public void actionPerformed( ActionEvent e ) { - app.getCanvas().setCanvasListener( - new ExtremesListener( app.getCanvas() ) ); + app.getCanvas().setCanvasListener( new ExtremesListener( app.getCanvas() ) ); } } diff --git a/src/jdrafting/gui/controller/actions/MathFunctionAction.java b/src/jdrafting/gui/controller/actions/MathFunctionAction.java index 5945c6d..4152b30 100644 --- a/src/jdrafting/gui/controller/actions/MathFunctionAction.java +++ b/src/jdrafting/gui/controller/actions/MathFunctionAction.java @@ -3,10 +3,13 @@ import static jdrafting.gui.JDUtils.getLargeIcon; import static jdrafting.gui.JDUtils.getSmallIcon; +import java.awt.Desktop; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; +import java.io.IOException; +import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; @@ -15,10 +18,12 @@ import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JDialog; +import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField; import javax.swing.KeyStroke; +import javax.swing.event.HyperlinkEvent; import jdrafting.gui.Application; import jdrafting.gui.JDUtils; @@ -26,6 +31,7 @@ import jme.Expresion; import jme.excepciones.ExpresionException; import jme.terminales.RealDoble; +import static jdrafting.gui.JDUtils.getLocaleText; @SuppressWarnings("serial") public class MathFunctionAction extends AbstractAction @@ -37,8 +43,8 @@ public MathFunctionAction( Application app ) { this.app = app; - putValue( NAME, "Math function" ); - putValue( SHORT_DESCRIPTION, "Create graph from function" ); + putValue( NAME, getLocaleText( "func" ) ); + putValue( SHORT_DESCRIPTION, getLocaleText( "func_des" ) ); putValue( MNEMONIC_KEY, JDUtils.getLocaleMnemonic( "mne_jme" ) ); putValue( ACCELERATOR_KEY, KeyStroke.getKeyStroke( "typed ¡" ) ); putValue( SMALL_ICON, getSmallIcon( "jme.png" ) ); @@ -61,30 +67,46 @@ private class JMEDialog extends JDialog { private JMEDialog() { - super( app, "jme params dialog", true ); - setLayout( new GridLayout( 5, 2, 4, 4 ) ); - add( new JLabel( - "jme examples -> f(x):=cos(x) " - + "|| f(t):=[cos(t),3*sin(t)]", - JLabel.RIGHT ) ); + super( app, getLocaleText( "jme_dlg" ), true ); + setLayout( new GridLayout( 6, 2, 4, 4 ) ); + add( new JLabel() ); + JEditorPane ep = new JEditorPane( "text/html", + "" + + getLocaleText( "jme_doc" ) + + "" ); + ep.setEditable( false ); + ep.getCaret().deinstall( ep ); // non-selectable + ep.addHyperlinkListener( ev -> { + if ( ev.getEventType().equals( HyperlinkEvent.EventType.ACTIVATED ) + && Desktop.isDesktopSupported() + && Desktop.getDesktop().isSupported( Desktop.Action.BROWSE ) ) + { + try { Desktop.getDesktop().browse( ev.getURL().toURI() ); } + catch ( URISyntaxException | IOException ex ) {} + } + }); + add( ep ); + add( new JLabel( "JME " + + getLocaleText( "jme_examples" ) + + " -> f(x):=cos(x) " + + "|| f(t):=[cos(t),3*sin(t)]", + JLabel.RIGHT ) ); JTextField tfExpression = new JTextField( - jmeParams != null - ? ( (Expresion) jmeParams.get( "expression" ) ).entrada() - : "" ); + jmeParams != null + ? ( (Expresion) jmeParams.get( "expression" ) ).entrada() + : "" ); add( tfExpression ); - add( new JLabel( "Min 'x' value", JLabel.RIGHT ) ); - JTextField tfminX = new JTextField( - jmeParams != null - ? jmeParams.get( "xmin" ).toString() - : "-10" ); + add( new JLabel( getLocaleText( "jme_min" ), JLabel.RIGHT ) ); + JTextField tfminX = new JTextField( jmeParams != null + ? jmeParams.get( "xmin" ).toString() + : "-10" ); add( tfminX ); - add( new JLabel( "Max 'x' value", JLabel.RIGHT ) ); - JTextField tfmaxX = new JTextField( - jmeParams != null - ? jmeParams.get( "xmax" ).toString() - : "10" ); + add( new JLabel( getLocaleText( "jme_max" ), JLabel.RIGHT ) ); + JTextField tfmaxX = new JTextField( jmeParams != null + ? jmeParams.get( "xmax" ).toString() + : "10" ); add( tfmaxX ); - add( new JLabel( "Number of intervals", JLabel.RIGHT ) ); + add( new JLabel( getLocaleText( "jme_intervals" ), JLabel.RIGHT ) ); JTextField tfIntervals = new JTextField( jmeParams != null ? jmeParams.get( "intervals" ).toString() diff --git a/src/jdrafting/gui/controller/actions/MediatrixAction.java b/src/jdrafting/gui/controller/actions/MediatrixAction.java index 466607c..f4d898d 100644 --- a/src/jdrafting/gui/controller/actions/MediatrixAction.java +++ b/src/jdrafting/gui/controller/actions/MediatrixAction.java @@ -27,8 +27,7 @@ public MediatrixAction( Application app ) putValue( NAME, getLocaleText( "mediatrix" ) ); putValue( SHORT_DESCRIPTION, getLocaleText( "mediatrix_des" ) ); putValue( MNEMONIC_KEY, JDUtils.getLocaleMnemonic( "mne_mediatrix" ) ); - putValue( ACCELERATOR_KEY, - KeyStroke.getKeyStroke( KeyEvent.VK_3, InputEvent.ALT_MASK ) ); + putValue( ACCELERATOR_KEY, KeyStroke.getKeyStroke( KeyEvent.VK_3, InputEvent.ALT_MASK ) ); putValue( SMALL_ICON, getSmallIcon( "mediatrix.png" ) ); putValue( LARGE_ICON_KEY, getLargeIcon( "mediatrix.png" ) ); } @@ -36,7 +35,6 @@ public MediatrixAction( Application app ) @Override public void actionPerformed(ActionEvent e) { - app.getCanvas().setCanvasListener( - new MediatrixListener( app.getCanvas() ) ); + app.getCanvas().setCanvasListener( new MediatrixListener( app.getCanvas() ) ); } } diff --git a/src/jdrafting/gui/controller/actions/OpenAction.java b/src/jdrafting/gui/controller/actions/OpenAction.java index e87bdfb..41385fd 100644 --- a/src/jdrafting/gui/controller/actions/OpenAction.java +++ b/src/jdrafting/gui/controller/actions/OpenAction.java @@ -114,8 +114,7 @@ public void propertyChange( PropertyChangeEvent e ) { String propertyName = e.getPropertyName(); - if ( propertyName - .equals( JFileChooser.SELECTED_FILE_CHANGED_PROPERTY ) ) + if ( propertyName.equals( JFileChooser.SELECTED_FILE_CHANGED_PROPERTY ) ) { File selected = (File) e.getNewValue(); @@ -143,15 +142,19 @@ public void paintComponent( Graphics g ) if ( exercise != null ) { setBackground( exercise.getBackgroundColor() ); + Graphics2D g2 = (Graphics2D) g; - Rectangle2D bounds = exercise.getBounds(); + // High quality render + JDUtils.setHighQualityRender( g2 ); + + final Rectangle2D bounds = exercise.getBounds(); int width = SIZE; int height = Math.min( getPreferredSize().height, - (int) ( width * bounds.getHeight() / bounds.getWidth() ) ); + (int) ( width * bounds.getHeight() / bounds.getWidth() ) ); CanvasPanel.drawExercise( g2, CanvasPanel.getTransform( - new Viewport( bounds ), - new Viewport( 0, width, 0, height ) ), - exercise, new HashSet<>(), false ); + new Viewport( bounds ), + new Viewport( 0, width, 0, height ) ), + exercise, new HashSet<>(), false ); } else setBackground( fileChooser.getBackground() ); diff --git a/src/jdrafting/gui/controller/actions/ParabolaAction.java b/src/jdrafting/gui/controller/actions/ParabolaAction.java index c9feed0..1a58c7b 100644 --- a/src/jdrafting/gui/controller/actions/ParabolaAction.java +++ b/src/jdrafting/gui/controller/actions/ParabolaAction.java @@ -36,7 +36,6 @@ public ParabolaAction( Application app ) @Override public void actionPerformed(ActionEvent e) { - app.getCanvas().setCanvasListener( - new ParabolaListener( app.getCanvas() ) ); + app.getCanvas().setCanvasListener( new ParabolaListener( app.getCanvas() ) ); } } diff --git a/src/jdrafting/gui/controller/actions/SaveAction.java b/src/jdrafting/gui/controller/actions/SaveAction.java index 71e661f..6e7e3f9 100644 --- a/src/jdrafting/gui/controller/actions/SaveAction.java +++ b/src/jdrafting/gui/controller/actions/SaveAction.java @@ -48,8 +48,7 @@ public SaveAction( Application app, boolean as ) KeyStroke.getKeyStroke( KeyEvent.VK_S, InputEvent.CTRL_MASK ) ); } else - putValue( MNEMONIC_KEY, - JDUtils.getLocaleMnemonic( "mne_save_as" ) ); + putValue( MNEMONIC_KEY, JDUtils.getLocaleMnemonic( "mne_save_as" ) ); putValue( SMALL_ICON, getSmallIcon( "save.png" ) ); putValue( LARGE_ICON_KEY, getLargeIcon( "save.png" ) ); diff --git a/src/jdrafting/gui/controller/actions/SaveImageAction.java b/src/jdrafting/gui/controller/actions/SaveImageAction.java index 05d5117..3b5c098 100644 --- a/src/jdrafting/gui/controller/actions/SaveImageAction.java +++ b/src/jdrafting/gui/controller/actions/SaveImageAction.java @@ -225,6 +225,9 @@ private BufferedImage createBImage( int width, int height, boolean text ) new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB ); Graphics2D g2 = (Graphics2D) img.getGraphics(); + + // High quality render + JDUtils.setHighQualityRender( g2 ); // draw background in image g2.setColor( fileChooser.checkBackground.isSelected() @@ -246,9 +249,9 @@ private class ImageChooser extends JFileChooser private JTextField textWidth = new JTextField( "1000" ); private JTextField textHeight = new JTextField(); private JCheckBox checkBackground = new JCheckBox( - getLocaleText( "save_image_acce2" ), true ); + getLocaleText( "save_image_acce2" ), true ); private JCheckBox checkText = new JCheckBox( - getLocaleText( "save_image_acce3" ), app.isVisibleNames() ); + getLocaleText( "save_image_acce3" ), app.isVisibleNames() ); private JLabel labelImage = new JLabel(); private ImageChooser() @@ -262,9 +265,8 @@ public void insertUpdate(DocumentEvent e) { try { - textHeight.setText( - String.valueOf( getAutomaticHeight( - Integer.parseInt( textWidth.getText() ) ) ) ); + textHeight.setText( String.valueOf( getAutomaticHeight( + Integer.parseInt( textWidth.getText() ) ) ) ); } catch ( NumberFormatException ex ) {} } @@ -287,13 +289,13 @@ public void changedUpdate(DocumentEvent e) public void itemStateChanged( ItemEvent e ) { labelImage.setIcon( new ImageIcon( - createBImage( MINI_SIZE, MINI_SIZE, false ) ) ); + createBImage( MINI_SIZE, MINI_SIZE, false ) ) ); } }); JPanel panel = new JPanel(); panel.setBorder( BorderFactory.createTitledBorder( - getLocaleText( "save_image_acce1" ) ) ); + getLocaleText( "save_image_acce1" ) ) ); GroupLayout layout = new GroupLayout( panel ); panel.setLayout( layout ); @@ -301,8 +303,7 @@ public void itemStateChanged( ItemEvent e ) layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup( layout.createSequentialGroup() - .addGroup( layout.createParallelGroup( - GroupLayout.Alignment.CENTER ) + .addGroup( layout.createParallelGroup( GroupLayout.Alignment.CENTER ) .addComponent( labelImage ) .addGroup( layout.createSequentialGroup() .addComponent( labelWidth ) @@ -314,12 +315,10 @@ public void itemStateChanged( ItemEvent e ) .addComponent( checkText ) ) ); layout.setVerticalGroup( layout.createSequentialGroup() .addComponent( labelImage ) - .addGroup( layout.createParallelGroup( - GroupLayout.Alignment.BASELINE ) + .addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE ) .addComponent( labelWidth ) .addComponent( textWidth ) ) - .addGroup( layout.createParallelGroup( - GroupLayout.Alignment.BASELINE ) + .addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE ) .addComponent( labelHeight ) .addComponent( textHeight ) ) .addComponent( checkBackground ) diff --git a/src/jdrafting/gui/controller/actions/SegmentAction.java b/src/jdrafting/gui/controller/actions/SegmentAction.java index f26d592..162cebc 100644 --- a/src/jdrafting/gui/controller/actions/SegmentAction.java +++ b/src/jdrafting/gui/controller/actions/SegmentAction.java @@ -36,7 +36,6 @@ public SegmentAction( Application app ) @Override public void actionPerformed(ActionEvent e) { - app.getCanvas().setCanvasListener( - new SegmentListener( app.getCanvas() ) ); + app.getCanvas().setCanvasListener( new SegmentListener( app.getCanvas() ) ); } } diff --git a/src/jdrafting/gui/controller/mouse/AngleListener.java b/src/jdrafting/gui/controller/mouse/AngleListener.java index 9bc6a7a..8dd25d7 100644 --- a/src/jdrafting/gui/controller/mouse/AngleListener.java +++ b/src/jdrafting/gui/controller/mouse/AngleListener.java @@ -26,8 +26,7 @@ */ public class AngleListener extends AbstractCanvasMouseListener { - private static final Cursor CURSOR = - JDUtils.getCustomCursor( "angle_cursor.png" ); + private static final Cursor CURSOR = JDUtils.getCustomCursor( "angle_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -80,12 +79,13 @@ else if ( p1 == null ) Line2D segment = getSegment( logicMouse ); // add segment to exercise - app.addShapeFromIterator( segment.getPathIterator( null ), "", "", + app.addShapeFromIterator( segment.getPathIterator( null ), "", + getLocaleText( "new_segment" ), app.getColor(), app.getStroke() ); if ( isTwoSides() ) // add first side - app.addShapeFromIterator( - new Line2D.Double( vertex, p1 ).getPathIterator( null ), - "", "", app.getColor(), app.getStroke() ); + app.addShapeFromIterator( new Line2D.Double( vertex, p1 ).getPathIterator( null ), + "", getLocaleText( "new_segment" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); @@ -110,8 +110,7 @@ public void paintTool( Graphics2D g2 ) g2.setColor( Application.toolMainColor ); // draw first side - Line2D line1 = - new Line2D.Double( vertex, p1 == null ? logicMouse : p1 ); + Line2D line1 = new Line2D.Double( vertex, p1 == null ? logicMouse : p1 ); g2.draw( transform.createTransformedShape( line1 ) ); if ( p1 != null ) @@ -121,7 +120,7 @@ public void paintTool( Graphics2D g2 ) g2.draw( transform.createTransformedShape( line2 ) ); // draw angle - double ang = Math.toDegrees( JDMath.lineAng( line1, line2 ) ); + double ang = Math.toDegrees( JDMath.lineAng( line1, line2 ) ); double dist = Math.min( vertex.distance( p1 ), vertex.distance( line2.getP2() ) ) / 2.; double offang = Math.toDegrees( Math.atan2( @@ -153,7 +152,7 @@ public void paintTool( Graphics2D g2 ) } } } - + // --- HELPERS --- diff --git a/src/jdrafting/gui/controller/mouse/ArcListener.java b/src/jdrafting/gui/controller/mouse/ArcListener.java index c210fb5..8f0b6da 100644 --- a/src/jdrafting/gui/controller/mouse/ArcListener.java +++ b/src/jdrafting/gui/controller/mouse/ArcListener.java @@ -84,17 +84,15 @@ else if ( start == null ) // create arc double radius = center.distance( end ); - double startAng = Math.toDegrees( vectorArg( - vector( center, start ) ) ); - Arc2D arc = new Arc2D.Double( - center.getX() - radius, center.getY() - radius, - 2 * radius, 2 * radius, - -startAng, -getArcExtent( end, logicMouse ), Arc2D.OPEN ); + double startAng = Math.toDegrees( vectorArg( vector( center, start ) ) ); + Arc2D arc = new Arc2D.Double( center.getX() - radius, center.getY() - radius, + 2 * radius, 2 * radius, + -startAng, -getArcExtent( end, logicMouse ), Arc2D.OPEN ); double flatness = arc.getWidth() / app.getFlatnessValue(); // add shape to exercise - app.addShapeFromIterator( arc.getPathIterator( null, flatness ), - "", "", app.getColor(), app.getStroke() ); + app.addShapeFromIterator( arc.getPathIterator( null, flatness ), "", + getLocaleText( "new_arc" ), app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); @@ -115,8 +113,7 @@ public void paintTool( Graphics2D g2 ) Point2D logicMouse = canvas.adjustToPoint( mouse().getPoint() ); // set style - g2.setStroke( new BasicStroke( 1f, BasicStroke.CAP_ROUND, - BasicStroke.JOIN_ROUND ) ); + g2.setStroke( new BasicStroke( 1f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) ); g2.setColor( Application.toolMainColor ); // draw center-start radius and circumference diff --git a/src/jdrafting/gui/controller/mouse/ArrowListener.java b/src/jdrafting/gui/controller/mouse/ArrowListener.java index 2eb5a9c..5080714 100644 --- a/src/jdrafting/gui/controller/mouse/ArrowListener.java +++ b/src/jdrafting/gui/controller/mouse/ArrowListener.java @@ -71,7 +71,8 @@ public void mouseReleased( MouseEvent e ) { // add shape to exercise Path2D line = getArrow( logicMouse ); - app.addShapeFromIterator( line.getPathIterator( null ), "", "", + app.addShapeFromIterator( line.getPathIterator( null ), "", + getLocaleText( "new_arrow" ), app.getColor(), app.getStroke() ); // back to select mode @@ -91,8 +92,7 @@ public void paintTool( Graphics2D g2 ) g2.setStroke( new BasicStroke( 1f ) ); g2.setColor( Application.toolMainColor ); - g2.draw( canvas.getTransform().createTransformedShape( - getArrow( logicMouse ) ) ); + g2.draw( canvas.getTransform().createTransformedShape( getArrow( logicMouse ) ) ); } } diff --git a/src/jdrafting/gui/controller/mouse/CircumferenceListener.java b/src/jdrafting/gui/controller/mouse/CircumferenceListener.java index 97a30cc..5589d2d 100644 --- a/src/jdrafting/gui/controller/mouse/CircumferenceListener.java +++ b/src/jdrafting/gui/controller/mouse/CircumferenceListener.java @@ -88,21 +88,21 @@ public String getUndoPresentationName() } }; // add circumference - app.addShapeFromIterator( - circ.getPathIterator( null, flatness ), "", "", - app.getColor(), app.getStroke(), transaction ); + app.addShapeFromIterator( circ.getPathIterator( null, flatness ), "", + getLocaleText( "new_circumference" ), + app.getColor(), app.getStroke(), transaction ); // add center - app.addShapeFromIterator( - new JDPoint( center ).getPathIterator( null ), "", "center", - app.getPointColor(), app.getPointStroke(), transaction ); + app.addShapeFromIterator( new JDPoint( center ).getPathIterator( null ), "", + getLocaleText( "new_circumference_center" ), + app.getPointColor(), app.getPointStroke(), transaction ); transaction.end(); app.undoSupport.postEdit( transaction ); } else // add circumference - app.addShapeFromIterator( - circ.getPathIterator( null, flatness ), "", "", - app.getColor(), app.getStroke() ); + app.addShapeFromIterator( circ.getPathIterator( null, flatness ), "", + getLocaleText( "new_circumference" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/EllipseListener.java b/src/jdrafting/gui/controller/mouse/EllipseListener.java index d42faa9..f42f1c4 100644 --- a/src/jdrafting/gui/controller/mouse/EllipseListener.java +++ b/src/jdrafting/gui/controller/mouse/EllipseListener.java @@ -94,22 +94,20 @@ public String getUndoPresentationName() // add ellipse Rectangle2D bounds = ellipse.getBounds2D(); - app.addShapeFromIterator( - ellipse.getPathIterator( null, flatness ), "", "", - app.getColor(), app.getStroke(), transaction ); + app.addShapeFromIterator( ellipse.getPathIterator( null, flatness ), "", + getLocaleText( "new_ellipse" ), + app.getColor(), app.getStroke(), transaction ); // add axis - Line2D axisH = new Line2D.Double( - bounds.getMinX(), bounds.getCenterY(), - bounds.getMaxX(), bounds.getCenterY() ); - Line2D axisV = new Line2D.Double( - bounds.getCenterX(), bounds.getMinY(), - bounds.getCenterX(), bounds.getMaxY() ); - app.addShapeFromIterator( - axisH.getPathIterator( null ), "", "major axis", - app.getColor(), app.getStroke(), transaction ); - app.addShapeFromIterator( - axisV.getPathIterator( null ), "", "minor axis", - app.getColor(), app.getStroke(), transaction ); + Line2D axisH = new Line2D.Double( bounds.getMinX(), bounds.getCenterY(), + bounds.getMaxX(), bounds.getCenterY() ); + Line2D axisV = new Line2D.Double( bounds.getCenterX(), bounds.getMinY(), + bounds.getCenterX(), bounds.getMaxY() ); + app.addShapeFromIterator( axisH.getPathIterator( null ), "", + getLocaleText( "new_h_axis" ), + app.getColor(), app.getStroke(), transaction ); + app.addShapeFromIterator( axisV.getPathIterator( null ), "", + getLocaleText( "new_v_axis" ), + app.getColor(), app.getStroke(), transaction ); // add focuses double w = ellipse.getWidth() / 2, h = ellipse.getHeight() / 2; Point2D f1, f2; @@ -129,22 +127,20 @@ public String getUndoPresentationName() f2 = new Point2D.Double( bounds.getCenterX(), bounds.getCenterY() - f ); } - app.addShapeFromIterator( - new JDPoint( f1 ).getPathIterator( null ), - "", getLocaleText( "new_focus" ), app.getPointColor(), - app.getPointStroke(), transaction ); - app.addShapeFromIterator( - new JDPoint( f2 ).getPathIterator( null ), - "", getLocaleText( "new_focus" ), app.getPointColor(), - app.getPointStroke(), transaction ); + app.addShapeFromIterator( new JDPoint( f1 ).getPathIterator( null ), "", + getLocaleText( "new_focus" ) + " 1", app.getPointColor(), + app.getPointStroke(), transaction ); + app.addShapeFromIterator( new JDPoint( f2 ).getPathIterator( null ), "", + getLocaleText( "new_focus" ) + " 2", + app.getPointColor(), app.getPointStroke(), transaction ); transaction.end(); app.undoSupport.postEdit( transaction ); } else - app.addShapeFromIterator( - ellipse.getPathIterator( null, flatness ), "", "", - app.getColor(), app.getStroke() ); + app.addShapeFromIterator( ellipse.getPathIterator( null, flatness ), "", + getLocaleText( "new_ellipse" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/ExtremesListener.java b/src/jdrafting/gui/controller/mouse/ExtremesListener.java index 3e42ad4..b3e3139 100644 --- a/src/jdrafting/gui/controller/mouse/ExtremesListener.java +++ b/src/jdrafting/gui/controller/mouse/ExtremesListener.java @@ -91,14 +91,12 @@ public void mouseReleased( MouseEvent e ) @Override public String getRedoPresentationName() { - return - "Redo add extremes (" + edits.size() + " points)"; + return "Redo add extremes (" + edits.size() + " points)"; } @Override public String getUndoPresentationName() { - return - "Undo add extremes (" + edits.size() + " points)"; + return "Undo add extremes (" + edits.size() + " points)"; } }; diff --git a/src/jdrafting/gui/controller/mouse/FreeHandListener.java b/src/jdrafting/gui/controller/mouse/FreeHandListener.java index 33d03ee..ff4f7a7 100644 --- a/src/jdrafting/gui/controller/mouse/FreeHandListener.java +++ b/src/jdrafting/gui/controller/mouse/FreeHandListener.java @@ -1,5 +1,7 @@ package jdrafting.gui.controller.mouse; +import static jdrafting.gui.JDUtils.getLocaleText; + import java.awt.BasicStroke; import java.awt.Cursor; import java.awt.Graphics2D; @@ -79,8 +81,9 @@ public void mouseReleased( MouseEvent e ) if ( e.getClickCount() == 2 ) { // add free polyline to exercise - app.addShapeFromIterator( path.getPathIterator( null ), - "", "", app.getColor(), app.getStroke() ); + app.addShapeFromIterator( path.getPathIterator( null ), "", + getLocaleText( "new_free_hand" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/HyperbolaListener.java b/src/jdrafting/gui/controller/mouse/HyperbolaListener.java index 8b933d4..d7a0d4c 100644 --- a/src/jdrafting/gui/controller/mouse/HyperbolaListener.java +++ b/src/jdrafting/gui/controller/mouse/HyperbolaListener.java @@ -103,11 +103,11 @@ public String getUndoPresentationName() // add hyperbola branches app.addShapeFromIterator( ( (Path2D) map.get( "branch1" ) ).getPathIterator( null ), - "", getLocaleText( "new_hype_branch" ), app.getColor(), + "", getLocaleText( "new_hype_branch" ) + " 1", app.getColor(), app.getStroke(), transaction ); app.addShapeFromIterator( ( (Path2D) map.get( "branch2" ) ).getPathIterator( null ), - "", getLocaleText( "new_hype_branch" ), app.getColor(), + "", getLocaleText( "new_hype_branch" ) + " 2", app.getColor(), app.getStroke(), transaction ); // add more hyperbola elements if ( addMore() ) diff --git a/src/jdrafting/gui/controller/mouse/MathFunctionListener.java b/src/jdrafting/gui/controller/mouse/MathFunctionListener.java index 778cc41..339a410 100644 --- a/src/jdrafting/gui/controller/mouse/MathFunctionListener.java +++ b/src/jdrafting/gui/controller/mouse/MathFunctionListener.java @@ -24,8 +24,7 @@ */ public class MathFunctionListener extends AbstractCanvasMouseListener { - private static final Cursor CURSOR = - JDUtils.getCustomCursor( "jme_cursor.png" ); + private static final Cursor CURSOR = JDUtils.getCustomCursor( "jme_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -33,8 +32,7 @@ public class MathFunctionListener extends AbstractCanvasMouseListener private Point2D[] values; private Map jmeParams; - public MathFunctionListener( CanvasPanel canvas, - Map jmeParams ) + public MathFunctionListener( CanvasPanel canvas, Map jmeParams ) { super( canvas ); @@ -116,10 +114,9 @@ public void mouseReleased( MouseEvent e ) else { // add function to exercise - app.addShapeFromIterator( - getGraph( logicMouse ).getPathIterator( null ), - "", jmeParams.get( "expression" ).toString(), - app.getColor(), app.getStroke() ); + app.addShapeFromIterator( getGraph( logicMouse ).getPathIterator( null ), + "", jmeParams.get( "expression" ).toString(), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/ParabolaListener.java b/src/jdrafting/gui/controller/mouse/ParabolaListener.java index 4ed8ed3..d3f9112 100644 --- a/src/jdrafting/gui/controller/mouse/ParabolaListener.java +++ b/src/jdrafting/gui/controller/mouse/ParabolaListener.java @@ -97,36 +97,35 @@ public String getUndoPresentationName() Map map = getParabola( logicMouse ); // add parabola, bounds, vertex, focus, directrix app.addShapeFromIterator( ( (Path2D) map.get( "parabola" ) ) - .getPathIterator( null ), - "", "", app.getColor(), app.getStroke(), transaction ); + .getPathIterator( null ), "", + getLocaleText( "new_parabola" ), + app.getColor(), app.getStroke(), transaction ); app.addShapeFromIterator( ( (Rectangle2D) map.get( "bounds" ) ) - .getPathIterator( null ), - "", getLocaleText( "new_para_bounds" ), app.getColor(), - app.getStroke(), transaction ); + .getPathIterator( null ), "", + getLocaleText( "new_para_bounds" ), + app.getColor(), app.getStroke(), transaction ); app.addShapeFromIterator( ( (Line2D) map.get( "directrix" ) ) - .getPathIterator( null ), - "", getLocaleText( "new_directrix" ), app.getColor(), - app.getStroke(), transaction ); - app.addShapeFromIterator( - ( new JDPoint( (Point2D) map.get( "vertex" ) ) ) - .getPathIterator( null ), - "", getLocaleText( "new_para_vertex" ), - app.getPointColor(), app.getPointStroke(), transaction ); - app.addShapeFromIterator( - ( new JDPoint( (Point2D) map.get( "focus" ) ) ) - .getPathIterator( null ), - "", getLocaleText( "new_focus" ), app.getPointColor(), - app.getPointStroke(), transaction ); + .getPathIterator( null ), "", + getLocaleText( "new_directrix" ), + app.getColor(), app.getStroke(), transaction ); + app.addShapeFromIterator( ( new JDPoint( (Point2D) map.get( "vertex" ) ) ) + .getPathIterator( null ), "", + getLocaleText( "new_para_vertex" ), + app.getPointColor(), app.getPointStroke(), transaction ); + app.addShapeFromIterator( ( new JDPoint( (Point2D) map.get( "focus" ) ) ) + .getPathIterator( null ), "", + getLocaleText( "new_focus" ), + app.getPointColor(), app.getPointStroke(), transaction ); transaction.end(); app.undoSupport.postEdit( transaction ); } else // add parabola to exercise - app.addShapeFromIterator( - ( (Path2D) getParabola( logicMouse ).get( "parabola" ) ) - .getPathIterator( null ), - "", "", app.getColor(), app.getStroke() ); + app.addShapeFromIterator( ( (Path2D) getParabola( logicMouse ).get( "parabola" ) ) + .getPathIterator( null ), "", + getLocaleText( "new_parabola" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/PointListener.java b/src/jdrafting/gui/controller/mouse/PointListener.java index 02f6a50..d5496d0 100644 --- a/src/jdrafting/gui/controller/mouse/PointListener.java +++ b/src/jdrafting/gui/controller/mouse/PointListener.java @@ -1,5 +1,7 @@ package jdrafting.gui.controller.mouse; +import static jdrafting.gui.JDUtils.getLocaleText; + import java.awt.BasicStroke; import java.awt.Color; import java.awt.Cursor; @@ -12,10 +14,10 @@ import jdrafting.gui.CanvasPanel; import jdrafting.gui.JDUtils; + public class PointListener extends AbstractCanvasMouseListener { - private static final Cursor CURSOR = - JDUtils.getCustomCursor( "point_cursor.png" ); + private static final Cursor CURSOR = JDUtils.getCustomCursor( "point_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -59,8 +61,7 @@ public void mouseReleased( MouseEvent e ) if ( p != null ) point = new JDPoint( p ); else - point = new JDPoint( canvas.getInverseTransform().transform( - e.getPoint(), null ) ); + point = new JDPoint( canvas.getInverseTransform().transform( e.getPoint(), null ) ); } // add point to exercise @@ -71,7 +72,7 @@ public void mouseReleased( MouseEvent e ) ? app.getStroke() : app.getPointStroke(); app.addShapeFromIterator( point.getPathIterator( null ), - "", "", color, stroke ); + "", getLocaleText( "new_point" ), color, stroke ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); @@ -80,7 +81,7 @@ public void mouseReleased( MouseEvent e ) @Override public void paintTool( Graphics2D g2 ) { - int cross = 7; // cross size + int crossSize = 7; Point2D point = mouse().getPoint(); // adjust to intersection or vertex if ( !isFreePoint() ) @@ -90,15 +91,15 @@ public void paintTool( Graphics2D g2 ) if ( p != null ) { point = canvas.getTransform().transform( p, null ); - cross = 11; + crossSize = 11; } } g2.setColor( Application.toolMainColor ); g2.setStroke( new BasicStroke( 1f ) ); - g2.drawOval( (int) Math.round( point.getX() - cross / 2. ), - (int) Math.round( point.getY() - cross / 2. ), - cross, cross ); + g2.drawOval( (int) Math.round( point.getX() - crossSize / 2. ), + (int) Math.round( point.getY() - crossSize / 2. ), + crossSize, crossSize ); } // --- HELPERS diff --git a/src/jdrafting/gui/controller/mouse/PolygonListener.java b/src/jdrafting/gui/controller/mouse/PolygonListener.java index 2dee9e8..ed55bbd 100644 --- a/src/jdrafting/gui/controller/mouse/PolygonListener.java +++ b/src/jdrafting/gui/controller/mouse/PolygonListener.java @@ -14,15 +14,15 @@ import jdrafting.gui.CanvasPanel; import jdrafting.gui.JDUtils; +import static jdrafting.gui.JDUtils.getLocaleText; + /** * Creates a polygon or polyline using mouse control */ public class PolygonListener extends AbstractCanvasMouseListener { - private static final Cursor CURSOR_POLYGON = - JDUtils.getCustomCursor( "polygon_cursor.png" ); - private static final Cursor CURSOR_POLYLINE = - JDUtils.getCustomCursor( "polyline_cursor.png" ); + private static final Cursor CURSOR_POLYGON = JDUtils.getCustomCursor( "polygon_cursor.png" ); + private static final Cursor CURSOR_POLYLINE = JDUtils.getCustomCursor( "polyline_cursor.png" ); private final Cursor CURSOR; private CanvasPanel canvas; private Application app; @@ -71,8 +71,9 @@ public void mouseReleased( MouseEvent e ) //polygon.closePath(); // "Fragment" would ignore last side // add polygon to exercise - app.addShapeFromIterator( polygon.getPathIterator( null ), - "", "", app.getColor(), app.getStroke() ); + app.addShapeFromIterator( polygon.getPathIterator( null ), "", + getLocaleText( closed ? "new_polygon" : "new_polyline" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/RectangleListener.java b/src/jdrafting/gui/controller/mouse/RectangleListener.java index 4e5868d..ad35beb 100644 --- a/src/jdrafting/gui/controller/mouse/RectangleListener.java +++ b/src/jdrafting/gui/controller/mouse/RectangleListener.java @@ -45,8 +45,7 @@ public void mouseMoved( MouseEvent e ) if ( start == null ) return; // dynamic cursor - Point2D pos = - canvas.getInverseTransform().transform( e.getPoint(), null ); + Point2D pos = canvas.getInverseTransform().transform( e.getPoint(), null ); if ( ( pos.getX() - start.getX() ) * ( pos.getY() - start.getY() ) > 0 ) canvas.setCursor( new Cursor( Cursor.NE_RESIZE_CURSOR ) ); else @@ -73,9 +72,9 @@ public void mouseReleased( MouseEvent e ) else { // add rectangle to exercise - app.addShapeFromIterator( - getRectangle( logicMouse ).getPathIterator( null ), - "", "", app.getColor(), app.getStroke() ); + app.addShapeFromIterator( getRectangle( logicMouse ).getPathIterator( null ), "", + getLocaleText( isSquare() ? "new_square" : "new_rectangle" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/RegularPolygonListener.java b/src/jdrafting/gui/controller/mouse/RegularPolygonListener.java index 7900366..7c91d7b 100644 --- a/src/jdrafting/gui/controller/mouse/RegularPolygonListener.java +++ b/src/jdrafting/gui/controller/mouse/RegularPolygonListener.java @@ -26,8 +26,7 @@ */ public class RegularPolygonListener extends AbstractCanvasMouseListener { - private static final Cursor CURSOR = - JDUtils.getCustomCursor( "reg_poly_cursor.png" ); + private static final Cursor CURSOR = JDUtils.getCustomCursor( "reg_poly_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -97,33 +96,31 @@ public String getUndoPresentationName() Map map = getPolygon( logicMouse ); // add polygon - app.addShapeFromIterator( ( (Path2D) map.get( "polygon" ) ) - .getPathIterator( null ), - "", "", app.getColor(), app.getStroke(), transaction ); + app.addShapeFromIterator( ( (Path2D) map.get( "polygon" ) ).getPathIterator( null ), + "", getLocaleText( "new_regular_polygon" ), + app.getColor(), app.getStroke(), transaction ); // add center - app.addShapeFromIterator( - ( new JDPoint( (Point2D) map.get( "center" ) ) ) - .getPathIterator( null ), - "", getLocaleText( "new_center_reg" ), - app.getPointColor(), app.getPointStroke(), transaction ); + app.addShapeFromIterator( ( new JDPoint( (Point2D) map.get( "center" ) ) ) + .getPathIterator( null ), + "", getLocaleText( "new_center_reg" ), + app.getPointColor(), app.getPointStroke(), transaction ); // add circumference circumscribed double flatness = ( (Ellipse2D) map.get( "circumscribed" ) ) .getWidth() / app.getFlatnessValue(); - app.addShapeFromIterator( - ( (Ellipse2D) map.get( "circumscribed" ) ) - .getPathIterator( null, flatness ), - "", getLocaleText( "new_circumscribed" ), app.getColor(), - app.getStroke(), transaction ); + app.addShapeFromIterator( ( (Ellipse2D) map.get( "circumscribed" ) ) + .getPathIterator( null, flatness ), + "", getLocaleText( "new_circumscribed" ), app.getColor(), + app.getStroke(), transaction ); transaction.end(); app.undoSupport.postEdit( transaction ); } else // add polygon to exercise - app.addShapeFromIterator( - ( (Path2D) getPolygon( logicMouse ).get( "polygon" ) ) - .getPathIterator( null ), - "", "", app.getColor(), app.getStroke() ); + app.addShapeFromIterator( ( (Path2D) getPolygon( logicMouse ).get( "polygon" ) ) + .getPathIterator( null ), "", + getLocaleText( "new_regular_polygon" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/SegmentListener.java b/src/jdrafting/gui/controller/mouse/SegmentListener.java index 1a5b7bb..a98b5b4 100644 --- a/src/jdrafting/gui/controller/mouse/SegmentListener.java +++ b/src/jdrafting/gui/controller/mouse/SegmentListener.java @@ -91,24 +91,24 @@ public String getUndoPresentationName() } }; // add segment - app.addShapeFromIterator( line.getPathIterator( null ), "", "", - app.getColor(), app.getStroke(), transaction ); + app.addShapeFromIterator( line.getPathIterator( null ), "", + getLocaleText( "new_segment" ), + app.getColor(), app.getStroke(), transaction ); // add extremes - app.addShapeFromIterator( - new JDPoint( line.getP1() ).getPathIterator( null ), "", - "segment extreme", app.getPointColor(), - app.getPointStroke(), transaction ); - app.addShapeFromIterator( - new JDPoint( line.getP2() ).getPathIterator( null ), "", - "segment extreme", app.getPointColor(), - app.getPointStroke(), transaction ); + app.addShapeFromIterator( new JDPoint( line.getP1() ).getPathIterator( null ), "", + getLocaleText( "new_segment_extreme" ) + " 1", + app.getPointColor(), app.getPointStroke(), transaction ); + app.addShapeFromIterator( new JDPoint( line.getP2() ).getPathIterator( null ), "", + getLocaleText( "new_segment_extreme" ) + " 2", + app.getPointColor(), app.getPointStroke(), transaction ); transaction.end(); app.undoSupport.postEdit( transaction ); } else // add segment - app.addShapeFromIterator( line.getPathIterator( null ), - "", "", app.getColor(), app.getStroke() ); + app.addShapeFromIterator( line.getPathIterator( null ), "", + getLocaleText( "new_segment" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/SplineListener.java b/src/jdrafting/gui/controller/mouse/SplineListener.java index 8a39dd4..a7e52a8 100644 --- a/src/jdrafting/gui/controller/mouse/SplineListener.java +++ b/src/jdrafting/gui/controller/mouse/SplineListener.java @@ -6,6 +6,7 @@ import static jdrafting.geom.JDMath.sumVectors; import static jdrafting.geom.JDMath.vector; import static jdrafting.geom.JDMath.vectorArg; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; @@ -68,10 +69,10 @@ public void mouseReleased( MouseEvent e ) Path2D spline = (Path2D) getSpline( points )[0]; // add polygon to exercise - double flatness = - spline.getBounds2D().getWidth() / app.getFlatnessValue(); - app.addShapeFromIterator( spline.getPathIterator( null, flatness ), - "", "", app.getColor(), app.getStroke() ); + double flatness = spline.getBounds2D().getWidth() / app.getFlatnessValue(); + app.addShapeFromIterator( spline.getPathIterator( null, flatness ), "", + getLocaleText( "new_spline" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/TriangleListener.java b/src/jdrafting/gui/controller/mouse/TriangleListener.java index 8d5400c..6fa8d77 100644 --- a/src/jdrafting/gui/controller/mouse/TriangleListener.java +++ b/src/jdrafting/gui/controller/mouse/TriangleListener.java @@ -74,8 +74,9 @@ else if ( B == null ) Path2D triangle = getTriangle( logicMouse ); // add triangle to exercise - app.addShapeFromIterator( triangle.getPathIterator( null ), - "", "", app.getColor(), app.getStroke() ); + app.addShapeFromIterator( triangle.getPathIterator( null ), "", + getLocaleText( "new_triangle" ), + app.getColor(), app.getStroke() ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); diff --git a/src/jdrafting/gui/controller/mouse/VertexListener.java b/src/jdrafting/gui/controller/mouse/VertexListener.java index 346e158..7bb9d78 100644 --- a/src/jdrafting/gui/controller/mouse/VertexListener.java +++ b/src/jdrafting/gui/controller/mouse/VertexListener.java @@ -19,8 +19,7 @@ public class VertexListener extends AbstractCanvasMouseListener { - private static final Cursor CURSOR = - JDUtils.getCustomCursor( "vertex_cursor.png" ); + private static final Cursor CURSOR = JDUtils.getCustomCursor( "vertex_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/resources/language/language.properties b/src/jdrafting/resources/language/language.properties index 0de95a7..cd65396 100644 --- a/src/jdrafting/resources/language/language.properties +++ b/src/jdrafting/resources/language/language.properties @@ -106,6 +106,8 @@ parabola=Parabola parabola_des=Create parabola from rectangle bounds hyperbola=Hyperbola hyperbola_des=Create hyperbola from rectangle bounds +func=Function +func_des=Create graph from function ruler=Ruler ruler_des=Capture distance protractor=Protractor @@ -204,8 +206,33 @@ details=Details selected_shapes_msg=You must select at least one shape homo_dlg=Homothety factor dist_mult_dlg=Multiply distance by factor +jme_dlg=JME expression +jme_examples=examples +jme_doc=JME documentation +jme_min=Min 'x' or 't' value +jme_max=Max 'x' or 't' value +jme_intervals=Number of intervals // new shapes default description +new_point=point +new_segment=segment +new_segment_extreme=segment extreme +new_arc=arc +new_circumference=circumference +new_circumference_center=circumference center +new_arrow=arrow +new_triangle=triangle +new_rectangle=rectangle +new_square=square +new_regular_polygon=regular polygon +new_polygon=polygon +new_polyline=polyline +new_ellipse=ellipse +new_v_axis=vertical axis +new_h_axis=horizontal axis +new_parabola=parabola +new_spline=spline +new_free_hand=free hand new_midpoint=midpoint of new_vertex=vertex of new_extreme=extreme of @@ -229,7 +256,7 @@ new_hype_bounds=hyperbola bounds new_hype_center=hyperbola center new_main_axis=hyperbola main axis new_img_axis=hyperbola imaginary axis -new_circumscribed=circumference circumscribed +new_circumscribed=circumscribed circumference new_center_reg=regular polygon center // status msg diff --git a/src/jdrafting/resources/language/language_en.properties b/src/jdrafting/resources/language/language_en.properties index 0de95a7..62610b4 100644 --- a/src/jdrafting/resources/language/language_en.properties +++ b/src/jdrafting/resources/language/language_en.properties @@ -106,6 +106,8 @@ parabola=Parabola parabola_des=Create parabola from rectangle bounds hyperbola=Hyperbola hyperbola_des=Create hyperbola from rectangle bounds +func_des=Create graph from function +func=Function ruler=Ruler ruler_des=Capture distance protractor=Protractor @@ -204,8 +206,33 @@ details=Details selected_shapes_msg=You must select at least one shape homo_dlg=Homothety factor dist_mult_dlg=Multiply distance by factor +jme_dlg=JME expression +jme_examples=examples +jme_doc=JME documentation +jme_min=Min 'x' or 't' value +jme_max=Max 'x' or 't' value +jme_intervals=Number of intervals // new shapes default description +new_point=point +new_segment=segment +new_segment_extreme=segment extreme +new_arc=arc +new_circumference=circumference +new_circumference_center=circumference center +new_arrow=arrow +new_triangle=triangle +new_rectangle=rectangle +new_square=square +new_ellipse=ellipse +new_regular_polygon=regular polygon +new_polygon=polygon +new_polyline=polyline +new_v_axis=vertical axis +new_h_axis=horizontal axis +new_parabola=parabola +new_spline=spline +new_free_hand=free hand new_midpoint=midpoint of new_vertex=vertex of new_extreme=extreme of @@ -229,7 +256,7 @@ new_hype_bounds=hyperbola bounds new_hype_center=hyperbola center new_main_axis=hyperbola main axis new_img_axis=hyperbola imaginary axis -new_circumscribed=circumference circumscribed +new_circumscribed=circumscribed circumference new_center_reg=regular polygon center // status msg diff --git a/src/jdrafting/resources/language/language_es.properties b/src/jdrafting/resources/language/language_es.properties index 64c05b0..320d64c 100644 --- a/src/jdrafting/resources/language/language_es.properties +++ b/src/jdrafting/resources/language/language_es.properties @@ -106,6 +106,8 @@ parabola=Par parabola_des=Crear parábola a partir de rectángulo frontera hyperbola=Hipérbola hyperbola_des=Crear hipérbola a partir de rectángulo frontera +func_des=Crear gráfico desde función +func=Función ruler=Regla ruler_des=Capturar distancia protractor=Transportador @@ -204,8 +206,33 @@ details=Detalles selected_shapes_msg=Se debe seleccionar al menos una figura homo_dlg=Factor de homotecia dist_mult_dlg=Multiplicar distancia por factor +jme_dlg=Expresión JME +jme_examples=ejemplos +jme_doc=Documentación JME +jme_min=Mínimo valor 'x' o 't' +jme_max=Máximo valor 'x' o 't' +jme_intervals=Número de intervalos // new shapes default description +new_point=punto +new_segment=segmento +new_segment_extreme=extremo de segmento +new_arc=arco +new_circumference=circunferencia +new_circumference_center=centro circunferencia +new_arrow=flecha +new_triangle=triángulo +new_rectangle=rentángulo +new_square=cuadrado +new_regular_polygon=polígono regular +new_polygon=polígono +new_polyline=polilínea +new_ellipse=elipse +new_v_axis=eje vertical +new_h_axis=eje horizontal +new_parabola=parábola +new_spline=spline +new_free_hand=mano alzada new_midpoint=punto medio de new_vertex=vértice de new_extreme=extremo de