From ad417fec4d5b0bd83f31c5142fff8d452ab9433a Mon Sep 17 00:00:00 2001 From: Miguel Alejandro Moreno Barrientos Date: Sat, 23 Apr 2016 09:46:31 +0200 Subject: [PATCH] v0.7.1 --- src/jdrafting/gui/Application.java | 207 ++++++++---------- src/jdrafting/gui/CanvasPanel.java | 24 +- src/jdrafting/gui/EditShapeDialog.java | 17 +- src/jdrafting/gui/FileInfoDialog.java | 31 ++- src/jdrafting/gui/JDUtils.java | 134 ++++++++++++ src/jdrafting/gui/ShapeList.java | 5 +- .../gui/controller/actions/AboutAction.java | 13 +- .../gui/controller/actions/AngleAction.java | 6 +- .../gui/controller/actions/ArcAction.java | 6 +- .../gui/controller/actions/ArrowAction.java | 6 +- .../actions/AxialSymmetryAction.java | 6 +- .../controller/actions/BackwardAction.java | 6 +- .../controller/actions/BisectrixAction.java | 6 +- .../gui/controller/actions/BoundsAction.java | 6 +- .../controller/actions/CanvasColorAction.java | 8 +- .../controller/actions/CapableArcAction.java | 6 +- .../actions/CentralSymmetryAction.java | 6 +- .../actions/CircumferenceAction.java | 6 +- .../actions/CopySelectedAction.java | 6 +- .../actions/DeleteSelectedAction.java | 6 +- .../actions/DivisionPointsAction.java | 6 +- .../gui/controller/actions/EllipseAction.java | 6 +- .../gui/controller/actions/EndAction.java | 6 +- .../actions/ExerciseMetadataAction.java | 6 +- .../gui/controller/actions/ExitAction.java | 6 +- .../controller/actions/ExtremesAction.java | 6 +- .../controller/actions/EyedropperAction.java | 6 +- .../gui/controller/actions/ForwardAction.java | 6 +- .../controller/actions/FragmentAction.java | 6 +- .../controller/actions/FreeHandAction.java | 8 +- .../gui/controller/actions/FusionAction.java | 6 +- .../controller/actions/HomothetyAction.java | 17 +- .../actions/IntersectionsAction.java | 6 +- .../actions/InvertSelectionAction.java | 6 +- .../controller/actions/MediatrixAction.java | 6 +- .../controller/actions/MidpointAction.java | 6 +- .../actions/ModifySegmentAction.java | 6 +- .../controller/actions/MoveZBufferAction.java | 6 +- .../gui/controller/actions/NewAction.java | 6 +- .../gui/controller/actions/OpenAction.java | 8 +- .../controller/actions/ParallelAction.java | 6 +- .../controller/actions/PasteStyleAction.java | 6 +- .../actions/PerpendicularAction.java | 6 +- .../gui/controller/actions/PointAction.java | 6 +- .../controller/actions/PointColorAction.java | 8 +- .../controller/actions/PolyLineAction.java | 6 +- .../gui/controller/actions/PolygonAction.java | 6 +- .../controller/actions/ProtractorAction.java | 6 +- .../controller/actions/RectangleAction.java | 6 +- .../gui/controller/actions/RedoAction.java | 6 +- .../gui/controller/actions/RewindAction.java | 6 +- .../controller/actions/RotationAction.java | 6 +- .../gui/controller/actions/RulerAction.java | 6 +- .../gui/controller/actions/SaveAction.java | 30 +-- .../controller/actions/SaveImageAction.java | 10 +- .../gui/controller/actions/SegmentAction.java | 6 +- .../controller/actions/SelectAllAction.java | 6 +- .../controller/actions/SelectionAction.java | 6 +- .../controller/actions/ShapeColorAction.java | 8 +- .../gui/controller/actions/SplineAction.java | 6 +- .../controller/actions/TextVisibleAction.java | 6 +- .../controller/actions/TranslationAction.java | 6 +- .../gui/controller/actions/UndoAction.java | 6 +- .../gui/controller/actions/VertexAction.java | 6 +- .../gui/controller/actions/ZoomAllAction.java | 6 +- .../controller/actions/ZoomInOutAction.java | 6 +- .../gui/controller/mouse/AngleListener.java | 5 +- .../gui/controller/mouse/ArcListener.java | 5 +- .../gui/controller/mouse/ArrowListener.java | 5 +- .../mouse/AxialSymmetryListener.java | 5 +- .../controller/mouse/BisectrixListener.java | 24 +- .../gui/controller/mouse/BoundsListener.java | 5 +- .../controller/mouse/CapableArcListener.java | 10 +- .../mouse/CentralSymmetryListener.java | 5 +- .../mouse/CircumferenceListener.java | 5 +- .../mouse/DivisionPointsListener.java | 8 +- .../gui/controller/mouse/EllipseListener.java | 5 +- .../controller/mouse/ExtremesListener.java | 5 +- .../controller/mouse/EyedropperListener.java | 5 +- .../controller/mouse/FragmentListener.java | 5 +- .../controller/mouse/FreeHandListener.java | 7 +- .../gui/controller/mouse/HandListener.java | 9 +- .../controller/mouse/HomothetyListener.java | 5 +- .../controller/mouse/MediatrixListener.java | 5 +- .../controller/mouse/MidpointListener.java | 5 +- .../mouse/ModifySegmentListener.java | 5 +- .../controller/mouse/ParallelListener.java | 5 +- .../controller/mouse/PasteStyleListener.java | 5 +- .../mouse/PerpendicularListener.java | 5 +- .../gui/controller/mouse/PointListener.java | 5 +- .../gui/controller/mouse/PolygonListener.java | 7 +- .../controller/mouse/ProtractorListener.java | 10 +- .../controller/mouse/RectangleListener.java | 5 +- .../controller/mouse/RotationListener.java | 5 +- .../gui/controller/mouse/RulerListener.java | 5 +- .../gui/controller/mouse/SegmentListener.java | 5 +- .../controller/mouse/SelectionListener.java | 3 +- .../gui/controller/mouse/SplineListener.java | 5 +- .../controller/mouse/TranslationListener.java | 5 +- .../gui/controller/mouse/VertexListener.java | 5 +- .../resources/language/language.properties | 4 +- .../resources/language/language_en.properties | 4 +- .../resources/language/language_es.properties | 4 +- 103 files changed, 578 insertions(+), 476 deletions(-) create mode 100644 src/jdrafting/gui/JDUtils.java diff --git a/src/jdrafting/gui/Application.java b/src/jdrafting/gui/Application.java index 5a29409..6e04516 100644 --- a/src/jdrafting/gui/Application.java +++ b/src/jdrafting/gui/Application.java @@ -1,5 +1,8 @@ package jdrafting.gui; +import static jdrafting.gui.JDUtils.getLocaleText; +import static jdrafting.gui.JDUtils.getSmallIcon; + import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; @@ -9,8 +12,6 @@ import java.awt.FlowLayout; import java.awt.Font; import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; @@ -30,8 +31,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; import java.util.Set; import javax.swing.AbstractAction; @@ -42,7 +41,6 @@ import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; -import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JCheckBoxMenuItem; @@ -156,7 +154,7 @@ public class Application extends JFrame ////////////////////// // metainfo public static final String APPNAME = "JDrafting"; - public static final String VERSION = "0.1.7"; // spline, load file from console, camelcase in save actions, color dialogs improved, show/hide all + public static final String VERSION = "0.1.7.1"; // Some minor fixes public static final String AUTHOR = "Miguel Alejandro Moreno Barrientos"; public static final String COPYLEFT = "2016"; public static final String PROJECT_PAGE = @@ -183,7 +181,7 @@ public class Application extends JFrame private Exercise exercise; private Set selectedShapes; private double angle = 90.; - private double distance = Math.ulp( 0. ); + private double distance = 0.1; private boolean useDistance = false; private double flatnessValue = 10000.; // flatness for circumferences, arcs private String saveFilename; @@ -202,8 +200,8 @@ public class Application extends JFrame public JPanel centerPanel; public JPanel northPanel; public JPanel statusPanel; - public JPanel stylePanel; - public JPanel rulerProtPanel; + public JToolBar styleToolbar; + public JToolBar rulerProtToolbar; public CanvasPanel canvas; public JMenuBar menubar; public JMenu menuFile; @@ -271,7 +269,7 @@ public void windowClosing(WindowEvent e) ///////// // GUI // ///////// - + /** * Initialize GUI components */ @@ -279,9 +277,7 @@ private void initUI() { // config frame setIconImage( getSmallIcon( "jdrafting.png" ).getImage() ); - Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); - setPreferredSize( new Dimension( (int) ( size.getWidth() * 0.8 ), - (int) ( size.getHeight() * 0.9 ) ) ); + setPreferredSize( JDUtils.getScreenSize( 0.8f, 0.8f ) ); // --- MENUBAR setJMenuBar( menubar = new JMenuBar() ); @@ -320,20 +316,32 @@ private void initUI() // north panel contentPanel.add( northPanel = new JPanel(), BorderLayout.NORTH ); northPanel.setLayout( - new BoxLayout( northPanel, BoxLayout.LINE_AXIS ) ); + new BoxLayout( northPanel, BoxLayout.LINE_AXIS ) ); + JPanel auxPanel = new JPanel(); + northPanel.add( auxPanel ); + auxPanel.setBorder( + BorderFactory.createBevelBorder( BevelBorder.RAISED ) ); + auxPanel.setLayout( + new BoxLayout( auxPanel, BoxLayout.LINE_AXIS ) ); // style panel - northPanel.add( stylePanel = new JPanel() ); - stylePanel.setLayout( - new BoxLayout( stylePanel, BoxLayout.LINE_AXIS ) ); - stylePanel.setBorder( BorderFactory.createTitledBorder( + styleToolbar = new JToolBar( getLocaleText( "tit_style" ) ); + styleToolbar.addHierarchyListener( + (evt) -> Application.this.revalidate() ); + auxPanel.add( styleToolbar ); + styleToolbar.setLayout( + new BoxLayout( styleToolbar, BoxLayout.LINE_AXIS ) ); + styleToolbar.setBorder( BorderFactory.createTitledBorder( getLocaleText( "tit_style" ) ) ); // ruler & protractor panel - northPanel.add( rulerProtPanel = new JPanel() ); - rulerProtPanel.setLayout( - new BoxLayout( rulerProtPanel, BoxLayout.LINE_AXIS ) ); - rulerProtPanel.setBorder( BorderFactory.createTitledBorder( + rulerProtToolbar = + new JToolBar( getLocaleText( "ruler_prot" ) ); + rulerProtToolbar.addHierarchyListener( + (evt) -> Application.this.revalidate() ); + auxPanel.add( rulerProtToolbar ); + rulerProtToolbar.setLayout( + new BoxLayout( rulerProtToolbar, BoxLayout.LINE_AXIS ) ); + rulerProtToolbar.setBorder( BorderFactory.createTitledBorder( getLocaleText( "ruler_prot" ) ) ); - northPanel.add( Box.createHorizontalGlue() ); // status panel contentPanel.add( statusPanel = new JPanel( new FlowLayout( FlowLayout.LEFT ) ), @@ -353,21 +361,21 @@ private void initUI() BorderLayout.SOUTH ); // --- STYLE PANEL - stylePanel.add( Box.createHorizontalStrut( 3 ) ); + styleToolbar.add( Box.createHorizontalStrut( 3 ) ); // eyedropper button - stylePanel.add( buttonEyedropper = new JButton() ); - stylePanel.add( Box.createHorizontalStrut( 3 ) ); + styleToolbar.add( buttonEyedropper = new JButton() ); + styleToolbar.add( Box.createHorizontalStrut( 3 ) ); // paste style button - stylePanel.add( buttonPasteStyle = new JButton() ); - stylePanel.add( Box.createHorizontalStrut( 12 ) ); + styleToolbar.add( buttonPasteStyle = new JButton() ); + styleToolbar.add( Box.createHorizontalStrut( 12 ) ); // jlabel line thickness JLabel labelThickness = new JLabel( getLocaleText( "thickness" ), JLabel.RIGHT ); labelThickness.setMaximumSize( labelThickness.getPreferredSize() ); - stylePanel.add( labelThickness ); - stylePanel.add( Box.createHorizontalStrut( 3 ) ); + styleToolbar.add( labelThickness ); + styleToolbar.add( Box.createHorizontalStrut( 3 ) ); // line thikness spinner - stylePanel.add( spinThickness = new JSpinner( new SpinnerNumberModel( + styleToolbar.add( spinThickness = new JSpinner( new SpinnerNumberModel( getStroke().getLineWidth(), .1, Double.POSITIVE_INFINITY, 1. ) ) ); spinThickness.setPreferredSize( new Dimension( 60, 30 ) ); spinThickness.setMinimumSize( spinThickness.getPreferredSize() ); @@ -378,9 +386,9 @@ private void initUI() BasicStroke bs = (BasicStroke) comboLineStyle.getSelectedItem(); setStroke( JDStrokes.getStroke( bs, thickness ) ); }); - stylePanel.add( Box.createHorizontalStrut( 3 ) ); + styleToolbar.add( Box.createHorizontalStrut( 3 ) ); // line color button - stylePanel.add( buttonColor = new JButton() { + styleToolbar.add( buttonColor = new JButton() { @Override protected void paintComponent( Graphics g ) { super.paintComponent( g ); @@ -391,21 +399,21 @@ protected void paintComponent( Graphics g ) { buttonColor.setPreferredSize( new Dimension( 30, 30 ) ); buttonColor.setMinimumSize( buttonColor.getPreferredSize() ); buttonColor.setMaximumSize( buttonColor.getPreferredSize() ); - stylePanel.add( Box.createHorizontalStrut( 3 ) ); + styleToolbar.add( Box.createHorizontalStrut( 3 ) ); // jcombobox line style - stylePanel.add( comboLineStyle = new LineStyleComboBox( this ) ); + styleToolbar.add( comboLineStyle = new LineStyleComboBox( this ) ); comboLineStyle.setPreferredSize( new Dimension( 200, 30 ) ); comboLineStyle.setMinimumSize( new Dimension( 100, 30 ) ); comboLineStyle.setMaximumSize( comboLineStyle.getPreferredSize() ); - stylePanel.add( Box.createHorizontalStrut( 12 ) ); + styleToolbar.add( Box.createHorizontalStrut( 12 ) ); // jlabel point thickness JLabel labelPoint = new JLabel( getLocaleText( "point_thickness" ), JLabel.RIGHT ); labelPoint.setMaximumSize( labelPoint.getPreferredSize() ); - stylePanel.add( labelPoint ); - stylePanel.add( Box.createHorizontalStrut( 3 ) ); + styleToolbar.add( labelPoint ); + styleToolbar.add( Box.createHorizontalStrut( 3 ) ); // point thickness spinner - stylePanel.add( spinPointThickness = new JSpinner( + styleToolbar.add( spinPointThickness = new JSpinner( new SpinnerNumberModel( getPointStroke().getLineWidth(), .1, Double.POSITIVE_INFINITY, 1. ) ) ); spinPointThickness.setPreferredSize( new Dimension( 60, 30 ) ); @@ -421,9 +429,9 @@ protected void paintComponent( Graphics g ) { bs.getLineJoin(), bs.getMiterLimit(), bs.getDashArray(), bs.getDashPhase() ) ); }); - stylePanel.add( Box.createHorizontalStrut( 3 ) ); + styleToolbar.add( Box.createHorizontalStrut( 3 ) ); // point color button - stylePanel.add( buttonPointColor = new JButton() { + styleToolbar.add( buttonPointColor = new JButton() { @Override protected void paintComponent( Graphics g ) { super.paintComponent( g ); @@ -434,26 +442,26 @@ protected void paintComponent( Graphics g ) { buttonPointColor.setPreferredSize( new Dimension( 30, 30 ) ); buttonPointColor.setMinimumSize( buttonPointColor.getPreferredSize() ); buttonPointColor.setMaximumSize( buttonPointColor.getPreferredSize() ); - stylePanel.add( Box.createHorizontalStrut( 3 ) ); + styleToolbar.add( Box.createHorizontalStrut( 3 ) ); // --- RULER & PROTRACTOR PANEL - rulerProtPanel.add( Box.createHorizontalStrut( 3 ) ); + rulerProtToolbar.add( Box.createHorizontalStrut( 3 ) ); // ruler button - rulerProtPanel.add( buttonRuler = new JButton() ); - rulerProtPanel.add( Box.createHorizontalStrut( 3 ) ); + rulerProtToolbar.add( buttonRuler = new JButton() ); + rulerProtToolbar.add( Box.createHorizontalStrut( 3 ) ); // checkbox fixed distance - rulerProtPanel.add( checkRuler = + rulerProtToolbar.add( checkRuler = new JCheckBox( getLocaleText( "fix_dist" ) ) ); checkRuler.setSelected( isUsingRuler() ); checkRuler.setMaximumSize( checkRuler.getPreferredSize() ); checkRuler.setMinimumSize( checkRuler.getPreferredSize() ); checkRuler.addActionListener( evt -> setUseDistance( checkRuler.isSelected() ) ); - rulerProtPanel.add( Box.createHorizontalStrut( 12 ) ); + rulerProtToolbar.add( Box.createHorizontalStrut( 12 ) ); // protractor button - rulerProtPanel.add( buttonProtactor = new JButton() ); + rulerProtToolbar.add( buttonProtactor = new JButton() ); // spinner angle - rulerProtPanel.add( spinAngle = new JSpinner( new SpinnerNumberModel( + rulerProtToolbar.add( spinAngle = new JSpinner( new SpinnerNumberModel( getAngle(), 0., Math.nextDown( 360. ), 1. ) ) ); spinAngle.setPreferredSize( new Dimension( 70, 30 ) ); spinAngle.setMaximumSize( spinAngle.getPreferredSize() ); @@ -474,7 +482,7 @@ public void keyTyped(KeyEvent e) }); spinAngle.addChangeListener( evt -> setAngle( (double) spinAngle.getModel().getValue() ) ); - rulerProtPanel.add( new JLabel( getLocaleText( "degrees" ) ) ); + rulerProtToolbar.add( new JLabel( getLocaleText( "degrees" ) ) ); // final glue northPanel.add( Box.createHorizontalGlue() ); @@ -583,6 +591,29 @@ private void createActions() menuView.addSeparator(); // See/Hide toolbars List buttonList = new LinkedList<>(); + JCheckBoxMenuItem checkMenuItemStyleBar = new JCheckBoxMenuItem( + getLocaleText( "item_style" ), styleToolbar.isVisible() ); + checkMenuItemStyleBar.addActionListener( new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) + { + styleToolbar.setVisible( checkMenuItemStyleBar.isSelected() ); + } + }); + menuView.add( checkMenuItemStyleBar ); + buttonList.add( checkMenuItemStyleBar ); + JCheckBoxMenuItem checkMenuItemRulerProtBar = new JCheckBoxMenuItem( + getLocaleText( "item_ruler_prot" ), rulerProtToolbar.isVisible() ); + checkMenuItemRulerProtBar.addActionListener( new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) + { + rulerProtToolbar.setVisible( + checkMenuItemRulerProtBar.isSelected() ); + } + }); + menuView.add( checkMenuItemRulerProtBar ); + buttonList.add( checkMenuItemRulerProtBar ); JCheckBoxMenuItem checkMenuItemStatusBar = new JCheckBoxMenuItem( getLocaleText( "item_status" ), statusPanel.isVisible() ); checkMenuItemStatusBar.addActionListener( new AbstractAction() { @@ -606,8 +637,7 @@ public void actionPerformed(ActionEvent e) menuView.add( checkMenuItemActionBar ); buttonList.add( checkMenuItemActionBar ); JCheckBoxMenuItem checkMenuItemShapebar = new JCheckBoxMenuItem( - getLocaleText( "item_shape" ), - shapebar.isVisible() ); + getLocaleText( "item_shape" ), shapebar.isVisible() ); checkMenuItemShapebar.addActionListener( new AbstractAction() { @Override public void actionPerformed(ActionEvent e) @@ -618,8 +648,7 @@ public void actionPerformed(ActionEvent e) menuView.add( checkMenuItemShapebar ); buttonList.add( checkMenuItemShapebar ); JCheckBoxMenuItem checkMenuItemToolbar = new JCheckBoxMenuItem( - getLocaleText( "item_tool" ), - toolbar.isVisible() ); + getLocaleText( "item_tool" ), toolbar.isVisible() ); checkMenuItemToolbar.addActionListener( new AbstractAction() { @Override public void actionPerformed(ActionEvent e) @@ -1191,30 +1220,6 @@ public void openFile( File file ) } } - /** - * Get a text value in current language - * @param key the key in the language file - * @return the translated expression - */ - public static String getLocaleText( String key ) - { - try - { - ResourceBundle resource = ResourceBundle.getBundle( - "jdrafting.resources.language.language", locale ); - /*if ( !locale.equals( resource.getLocale() ) ) // go to English - throw new MissingResourceException( "fallback", "", key );*/ - - return resource.getString( key ); - } - catch ( MissingResourceException e ) // Default English - { - return ResourceBundle.getBundle( - "jdrafting.resources.language.language", Locale.ENGLISH ) - .getString( key ); - } - } - /** * Adds to exercise a Path2D representation of the shape with the * specified parameters. @@ -1291,46 +1296,6 @@ public int removeShape( JDraftingShape jdshape ) return removeShape( jdshape, null ); } - /** - * Scale an image from the image resource folder to a specified size - * @param name name of the file (from image resource folder) - * @param width new width - * @param height new height - * @return the scaled image - */ - public static ImageIcon getScaledIco( String name, int width, int height ) - { - return new ImageIcon( new ImageIcon( - Object.class - .getResource( "/jdrafting/resources/images/" + name ) ) - .getImage() - .getScaledInstance( width, height, Image.SCALE_SMOOTH ) ); - } - - /** - * Get small icons of the resource images. - * See {@link #getScaledIco(String, int, int)} - * @see #getScaledIco(String, int, int) - * @param name filename - * @return scaled image - */ - public static ImageIcon getSmallIcon( String name ) - { - return getScaledIco( name, 16, 16 ); - } - - /** - * Get large icons of the resource images. - * See {@link #getScaledIco(String, int, int)} - * @see #getScaledIco(String, int, int) - * @param name filename - * @return scaled image - */ - public static ImageIcon getLargeIcon( String name ) - { - return getScaledIco( name, 32, 32 ); - } - /** * Exit application */ @@ -1487,15 +1452,15 @@ public String getPresentationName() return "Remove " + jdshape.toShortString(); } } - - + + ////////////////// // GUI LAUNCHER // ////////////////// /** * Launch GUI - * @param args (ignored) // TODO + * @param args %1 filename to load */ public static void main( String[] args ) { diff --git a/src/jdrafting/gui/CanvasPanel.java b/src/jdrafting/gui/CanvasPanel.java index 89b7c42..718b923 100644 --- a/src/jdrafting/gui/CanvasPanel.java +++ b/src/jdrafting/gui/CanvasPanel.java @@ -2,7 +2,6 @@ import java.awt.BasicStroke; import java.awt.Color; -import java.awt.Cursor; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; @@ -10,7 +9,6 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.Shape; -import java.awt.Toolkit; import java.awt.geom.AffineTransform; import java.awt.geom.Line2D; import java.awt.geom.NoninvertibleTransformException; @@ -96,13 +94,12 @@ public CanvasPanel( Application app, Viewport viewport ) movementThread = new MoveCanvasThread(); movementThread.start(); } - - - public Application getApplication() { return app; } - + ///////////////////// // GETTERS/SETTERS // ///////////////////// + + public Application getApplication() { return app; } /** * Logic viewport of the canvas @@ -562,18 +559,6 @@ public static Rectangle2D getShapeCanvasBounds( JDraftingShape jdshape, bounds.getHeight() + lineWidth ); } - /** - * Load a custom mouse cursor by filename - * @param file filename - * @return a mouse cursor - */ - public static Cursor getCustomCursor( String file ) - { - return Toolkit.getDefaultToolkit().createCustomCursor( - Application.getScaledIco( "cursors/" + file, 32, 32 ).getImage(), - new Point( 0, 0 ), "custom cursor" ); - } - /** * Get current canvas mouse listener (segment tool, hand,...) * @return current listener @@ -625,7 +610,8 @@ public void run() { SwingUtilities.invokeLater( () -> { Point mouse = getMousePosition(); - if ( mouse == null || getCanvasListener() instanceof HandListener ) + if ( mouse == null + || getCanvasListener() instanceof HandListener ) { wait = MAX_WAIT; return; diff --git a/src/jdrafting/gui/EditShapeDialog.java b/src/jdrafting/gui/EditShapeDialog.java index 22469eb..61201f4 100644 --- a/src/jdrafting/gui/EditShapeDialog.java +++ b/src/jdrafting/gui/EditShapeDialog.java @@ -1,6 +1,6 @@ package jdrafting.gui; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BorderLayout; import java.awt.Dimension; @@ -16,7 +16,6 @@ import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JDialog; -import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -31,14 +30,10 @@ @SuppressWarnings("serial") public class EditShapeDialog extends JDialog { - public EditShapeDialog( JFrame parent, JDraftingShape jdshape ) + public EditShapeDialog( Application parent, JDraftingShape jdshape ) { super( parent, getLocaleText( "shape_prop" ), true ); - if ( !( getParent() instanceof Application ) ) - return; - Application app = (Application) getParent(); - JPanel panel = new JPanel( new BorderLayout() ); panel.setBorder( BorderFactory.createEmptyBorder( 6, 6, 6, 6 ) ); getContentPane().add( panel ); @@ -88,9 +83,9 @@ public void actionPerformed( ActionEvent e ) jdshape.setDescription( taDesc.getText() ); // refresh GUI - app.getCanvas().repaint(); - app.refreshUndoRedo(); - app.scrollList.repaint(); + parent.getCanvas().repaint(); + parent.refreshUndoRedo(); + parent.scrollList.repaint(); dispose(); } @@ -126,7 +121,7 @@ public void actionPerformed( ActionEvent e ) setDefaultCloseOperation( DISPOSE_ON_CLOSE ); pack(); - setLocationRelativeTo( null ); + setLocationRelativeTo( parent ); } @Override diff --git a/src/jdrafting/gui/FileInfoDialog.java b/src/jdrafting/gui/FileInfoDialog.java index 38c28c0..46098b0 100644 --- a/src/jdrafting/gui/FileInfoDialog.java +++ b/src/jdrafting/gui/FileInfoDialog.java @@ -1,5 +1,7 @@ package jdrafting.gui; +import static jdrafting.gui.JDUtils.getLocaleText; + import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; @@ -14,7 +16,6 @@ import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JDialog; -import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRootPane; @@ -26,13 +27,9 @@ @SuppressWarnings("serial") public class FileInfoDialog extends JDialog { - public FileInfoDialog( JFrame parent ) + public FileInfoDialog( Application parent ) { - super( parent, Application.getLocaleText( "exer_prop" ), true ); - - if ( !( getParent() instanceof Application ) ) - return; - Application app = (Application) getParent(); + super( parent, getLocaleText( "exer_prop" ), true ); JPanel panel = new JPanel( new BorderLayout() ); panel.setBorder( BorderFactory.createEmptyBorder( 6, 6, 6, 6 ) ); @@ -41,12 +38,12 @@ public FileInfoDialog( JFrame parent ) Box box = Box.createVerticalBox(); panel.add( box ); - JLabel ltitle = new JLabel( Application.getLocaleText( "title" ) ); + JLabel ltitle = new JLabel( getLocaleText( "title" ) ); ltitle.setAlignmentX( LEFT_ALIGNMENT ); box.add( ltitle ); final JTextField textTitle = - new JTextField( app.getExercise().getTitle() ); + new JTextField( parent.getExercise().getTitle() ); textTitle.setAlignmentX( LEFT_ALIGNMENT ); textTitle.setMaximumSize( new Dimension( Integer.MAX_VALUE, textTitle.getPreferredSize().height ) ); @@ -54,12 +51,12 @@ public FileInfoDialog( JFrame parent ) box.add( Box.createRigidArea( new Dimension( 0, 10 ) ) ); - JLabel lDesc = new JLabel( Application.getLocaleText( "exer_desc" ) ); + JLabel lDesc = new JLabel( getLocaleText( "exer_desc" ) ); lDesc.setAlignmentX( LEFT_ALIGNMENT ); box.add( lDesc ); final JTextArea textArea = - new JTextArea( app.getExercise().getDescription(), 8, 50 ); + new JTextArea( parent.getExercise().getDescription(), 8, 50 ); JScrollPane scrollArea = new JScrollPane( textArea ); scrollArea.setAlignmentX( LEFT_ALIGNMENT ); box.add( scrollArea ); @@ -73,21 +70,19 @@ public FileInfoDialog( JFrame parent ) box.add( btnPanel ); - JButton btnOk = - new JButton( Application.getLocaleText( "save_close" ) ); + JButton btnOk = new JButton( getLocaleText( "save_close" ) ); btnPanel.add( btnOk ); btnOk.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { - app.getExercise().setTitle( textTitle.getText() ); - app.getExercise().setDescription( textArea.getText() ); + parent.getExercise().setTitle( textTitle.getText() ); + parent.getExercise().setDescription( textArea.getText() ); setVisible( false ); dispose(); } } ); - JButton btnCancel = - new JButton( Application.getLocaleText( "cancel" ) ); + JButton btnCancel =new JButton( getLocaleText( "cancel" ) ); btnPanel.add( btnCancel ); btnCancel.addActionListener( new ActionListener() { @Override @@ -100,7 +95,7 @@ public void actionPerformed( ActionEvent e ) setDefaultCloseOperation( DISPOSE_ON_CLOSE ); pack(); - setLocationRelativeTo( null ); + setLocationRelativeTo( parent ); } @Override diff --git a/src/jdrafting/gui/JDUtils.java b/src/jdrafting/gui/JDUtils.java new file mode 100644 index 0000000..a287ebd --- /dev/null +++ b/src/jdrafting/gui/JDUtils.java @@ -0,0 +1,134 @@ +package jdrafting.gui; + +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Image; +import java.awt.Point; +import java.awt.Toolkit; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import java.util.stream.Stream; + +import javax.swing.ImageIcon; + +import jdrafting.geom.JDMath; + +/** + * Helper methods for JDrafting + */ +public class JDUtils +{ + /** + * Avoid instantiation + */ + private JDUtils() {} + + /** + * Get screen size, multiplied by factor + * @param ratioX factor width (value 1 for screen width) + * @param ratioY factor height (value 1 for screen height) + * @return + */ + public static Dimension getScreenSize( float ratioX, float ratioY ) + { + Dimension ssize = Toolkit.getDefaultToolkit().getScreenSize(); + + return new Dimension( JDMath.nearInt( ssize.getWidth() * ratioX ), + JDMath.nearInt( ssize.getHeight() * ratioY ) ); + } + + /** + * Get a text value in current language + * @param key the key in the language file + * @return the translated expression + */ + public static String getLocaleText( String key ) + { + try + { + ResourceBundle resource = ResourceBundle.getBundle( + "jdrafting.resources.language.language", Application.locale ); + /*if ( !locale.equals( resource.getLocale() ) ) // go to English + throw new MissingResourceException( "fallback", "", key );*/ + + return resource.getString( key ); + } + catch ( MissingResourceException e ) // Default English + { + return ResourceBundle.getBundle( + "jdrafting.resources.language.language", Locale.ENGLISH ) + .getString( key ); + } + } + + /** + * Scale an image from the image resource folder to a specified size + * @param name name of the file (from image resource folder) + * @param width new width + * @param height new height + * @return the scaled image + */ + public static ImageIcon getScaledIco( String name, int width, int height ) + { + return new ImageIcon( new ImageIcon( + Object.class + .getResource( "/jdrafting/resources/images/" + name ) ) + .getImage() + .getScaledInstance( width, height, Image.SCALE_SMOOTH ) ); + } + + /** + * Get small icons of the resource images. + * See {@link #getScaledIco(String, int, int)} + * @see #getScaledIco(String, int, int) + * @param name filename + * @return scaled image + */ + public static ImageIcon getSmallIcon( String name ) + { + return getScaledIco( name, 16, 16 ); + } + + /** + * Get large icons of the resource images. + * See {@link #getScaledIco(String, int, int)} + * @see #getScaledIco(String, int, int) + * @param name filename + * @return scaled image + */ + public static ImageIcon getLargeIcon( String name ) + { + return getScaledIco( name, 32, 32 ); + } + + /** + * Load a custom mouse cursor by filename + * @param file filename + * @return a mouse cursor + */ + public static Cursor getCustomCursor( String file ) + { + return Toolkit.getDefaultToolkit().createCustomCursor( + getScaledIco( "cursors/" + file, 32, 32 ).getImage(), + new Point( 0, 0 ), "custom cursor" ); + } + + /** + * Converts a name to a CamelCase string only with alphanumeric characters + * @param name a name + * @return CamelCase representation + */ + public static String camelCase( String name ) + { + String[] array = name.split( "[^a-zA-Z0-9]" ); + array = Stream.of( array ) + .filter( s -> !s.trim().isEmpty() ) + .map( + s -> Character.toUpperCase( s.charAt( 0 ) ) + s.substring( 1 ) ) + .toArray( String[]::new ); + name = String.join( "", array ); + + return name; + } +} diff --git a/src/jdrafting/gui/ShapeList.java b/src/jdrafting/gui/ShapeList.java index c316345..c51a7ab 100644 --- a/src/jdrafting/gui/ShapeList.java +++ b/src/jdrafting/gui/ShapeList.java @@ -21,7 +21,7 @@ import javax.swing.JPanel; import javax.swing.ListCellRenderer; import javax.swing.ListSelectionModel; -import javax.swing.border.EtchedBorder; +import javax.swing.border.BevelBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -124,8 +124,7 @@ public Component getListCellRendererComponent( removeAll(); setLayout( new BoxLayout( this, BoxLayout.LINE_AXIS ) ); setOpaque( true ); - setBorder( BorderFactory.createEtchedBorder( - EtchedBorder.LOWERED ) ); + setBorder( BorderFactory.createBevelBorder( BevelBorder.RAISED ) ); // index JLabel shapeIndex = new JLabel( index + 1 + ":" ); add( shapeIndex ); diff --git a/src/jdrafting/gui/controller/actions/AboutAction.java b/src/jdrafting/gui/controller/actions/AboutAction.java index 43d3516..90c24c0 100644 --- a/src/jdrafting/gui/controller/actions/AboutAction.java +++ b/src/jdrafting/gui/controller/actions/AboutAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +import static jdrafting.gui.JDUtils.getLargeIcon; +import static jdrafting.gui.JDUtils.getLocaleText; +import static jdrafting.gui.JDUtils.getSmallIcon; import java.awt.Desktop; import java.awt.event.ActionEvent; @@ -17,6 +17,7 @@ import javax.swing.event.HyperlinkListener; import jdrafting.gui.Application; +import jdrafting.gui.JDUtils; @SuppressWarnings("serial") public class AboutAction extends AbstractAction @@ -48,7 +49,7 @@ public void actionPerformed( ActionEvent e ) + "

" + "

" + Application.APPNAME + " " - + Application.getLocaleText( "app_des" ) + + getLocaleText( "app_des" ) + "

" + "

" + "GPLv3 license " @@ -83,7 +84,7 @@ public void hyperlinkUpdate( HyperlinkEvent e ) } }); JOptionPane.showMessageDialog( app, ep, "About " + Application.APPNAME, - JOptionPane.PLAIN_MESSAGE, - Application.getScaledIco( "jdrafting.png", 100, 100 ) ); + JOptionPane.PLAIN_MESSAGE, + JDUtils.getScaledIco( "jdrafting.png", 100, 100 ) ); } } diff --git a/src/jdrafting/gui/controller/actions/AngleAction.java b/src/jdrafting/gui/controller/actions/AngleAction.java index 2765a2d..b56d0e6 100644 --- a/src/jdrafting/gui/controller/actions/AngleAction.java +++ b/src/jdrafting/gui/controller/actions/AngleAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/ArcAction.java b/src/jdrafting/gui/controller/actions/ArcAction.java index 7f9236c..2034511 100644 --- a/src/jdrafting/gui/controller/actions/ArcAction.java +++ b/src/jdrafting/gui/controller/actions/ArcAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/ArrowAction.java b/src/jdrafting/gui/controller/actions/ArrowAction.java index 0889478..ad3de40 100644 --- a/src/jdrafting/gui/controller/actions/ArrowAction.java +++ b/src/jdrafting/gui/controller/actions/ArrowAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/AxialSymmetryAction.java b/src/jdrafting/gui/controller/actions/AxialSymmetryAction.java index 6ca9b2e..7212af9 100644 --- a/src/jdrafting/gui/controller/actions/AxialSymmetryAction.java +++ b/src/jdrafting/gui/controller/actions/AxialSymmetryAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/BackwardAction.java b/src/jdrafting/gui/controller/actions/BackwardAction.java index 1476aa4..a136870 100644 --- a/src/jdrafting/gui/controller/actions/BackwardAction.java +++ b/src/jdrafting/gui/controller/actions/BackwardAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/BisectrixAction.java b/src/jdrafting/gui/controller/actions/BisectrixAction.java index 7d6c1fb..4e9e816 100644 --- a/src/jdrafting/gui/controller/actions/BisectrixAction.java +++ b/src/jdrafting/gui/controller/actions/BisectrixAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/BoundsAction.java b/src/jdrafting/gui/controller/actions/BoundsAction.java index a2bc034..75935e5 100644 --- a/src/jdrafting/gui/controller/actions/BoundsAction.java +++ b/src/jdrafting/gui/controller/actions/BoundsAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/CanvasColorAction.java b/src/jdrafting/gui/controller/actions/CanvasColorAction.java index f913ee2..5fc24b5 100644 --- a/src/jdrafting/gui/controller/actions/CanvasColorAction.java +++ b/src/jdrafting/gui/controller/actions/CanvasColorAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; @@ -36,7 +36,7 @@ public CanvasColorAction( Application app ) jcc = new JColorChooser(); colorChooser = JColorChooser.createDialog( - app, getLocaleText( "background_color_des" ), false, jcc, + app, getLocaleText( "background_color_des" ), true, jcc, (evt) -> app.setBackColor( jcc.getColor() ), // ok null ); // cancel } diff --git a/src/jdrafting/gui/controller/actions/CapableArcAction.java b/src/jdrafting/gui/controller/actions/CapableArcAction.java index 9f0fe59..dea1e9a 100644 --- a/src/jdrafting/gui/controller/actions/CapableArcAction.java +++ b/src/jdrafting/gui/controller/actions/CapableArcAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/CentralSymmetryAction.java b/src/jdrafting/gui/controller/actions/CentralSymmetryAction.java index 52a32b1..2c8273e 100644 --- a/src/jdrafting/gui/controller/actions/CentralSymmetryAction.java +++ b/src/jdrafting/gui/controller/actions/CentralSymmetryAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/CircumferenceAction.java b/src/jdrafting/gui/controller/actions/CircumferenceAction.java index 336e05a..96a5d61 100644 --- a/src/jdrafting/gui/controller/actions/CircumferenceAction.java +++ b/src/jdrafting/gui/controller/actions/CircumferenceAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/CopySelectedAction.java b/src/jdrafting/gui/controller/actions/CopySelectedAction.java index fc6a26b..a5e3beb 100644 --- a/src/jdrafting/gui/controller/actions/CopySelectedAction.java +++ b/src/jdrafting/gui/controller/actions/CopySelectedAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/DeleteSelectedAction.java b/src/jdrafting/gui/controller/actions/DeleteSelectedAction.java index 0102405..adc20a4 100644 --- a/src/jdrafting/gui/controller/actions/DeleteSelectedAction.java +++ b/src/jdrafting/gui/controller/actions/DeleteSelectedAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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.KeyEvent; diff --git a/src/jdrafting/gui/controller/actions/DivisionPointsAction.java b/src/jdrafting/gui/controller/actions/DivisionPointsAction.java index d1f90ce..ea3a2cb 100644 --- a/src/jdrafting/gui/controller/actions/DivisionPointsAction.java +++ b/src/jdrafting/gui/controller/actions/DivisionPointsAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/EllipseAction.java b/src/jdrafting/gui/controller/actions/EllipseAction.java index 244a460..1c03fd9 100644 --- a/src/jdrafting/gui/controller/actions/EllipseAction.java +++ b/src/jdrafting/gui/controller/actions/EllipseAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/EndAction.java b/src/jdrafting/gui/controller/actions/EndAction.java index 151d6df..1261c40 100644 --- a/src/jdrafting/gui/controller/actions/EndAction.java +++ b/src/jdrafting/gui/controller/actions/EndAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/ExerciseMetadataAction.java b/src/jdrafting/gui/controller/actions/ExerciseMetadataAction.java index bcd4eda..12a03ed 100644 --- a/src/jdrafting/gui/controller/actions/ExerciseMetadataAction.java +++ b/src/jdrafting/gui/controller/actions/ExerciseMetadataAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/ExitAction.java b/src/jdrafting/gui/controller/actions/ExitAction.java index bbb7674..730d84d 100644 --- a/src/jdrafting/gui/controller/actions/ExitAction.java +++ b/src/jdrafting/gui/controller/actions/ExitAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/ExtremesAction.java b/src/jdrafting/gui/controller/actions/ExtremesAction.java index 4b0b697..9c059f2 100644 --- a/src/jdrafting/gui/controller/actions/ExtremesAction.java +++ b/src/jdrafting/gui/controller/actions/ExtremesAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/EyedropperAction.java b/src/jdrafting/gui/controller/actions/EyedropperAction.java index fe9b12c..3c84413 100644 --- a/src/jdrafting/gui/controller/actions/EyedropperAction.java +++ b/src/jdrafting/gui/controller/actions/EyedropperAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/ForwardAction.java b/src/jdrafting/gui/controller/actions/ForwardAction.java index dc2d5b3..555cb8b 100644 --- a/src/jdrafting/gui/controller/actions/ForwardAction.java +++ b/src/jdrafting/gui/controller/actions/ForwardAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/FragmentAction.java b/src/jdrafting/gui/controller/actions/FragmentAction.java index a59cd49..6132fa5 100644 --- a/src/jdrafting/gui/controller/actions/FragmentAction.java +++ b/src/jdrafting/gui/controller/actions/FragmentAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/FreeHandAction.java b/src/jdrafting/gui/controller/actions/FreeHandAction.java index 7df3e8c..2b6f4fe 100644 --- a/src/jdrafting/gui/controller/actions/FreeHandAction.java +++ b/src/jdrafting/gui/controller/actions/FreeHandAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; @@ -23,7 +23,7 @@ public FreeHandAction( Application app ) { this.app = app; - putValue( NAME, Application.getLocaleText( "free_hand" ) ); + putValue( NAME, getLocaleText( "free_hand" ) ); putValue( SHORT_DESCRIPTION, getLocaleText( "free_hand_des" ) ); putValue( MNEMONIC_KEY, KeyEvent.VK_F ); putValue( ACCELERATOR_KEY, diff --git a/src/jdrafting/gui/controller/actions/FusionAction.java b/src/jdrafting/gui/controller/actions/FusionAction.java index 2dc1c34..68c44fe 100644 --- a/src/jdrafting/gui/controller/actions/FusionAction.java +++ b/src/jdrafting/gui/controller/actions/FusionAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/HomothetyAction.java b/src/jdrafting/gui/controller/actions/HomothetyAction.java index 50f8ad0..44b5319 100644 --- a/src/jdrafting/gui/controller/actions/HomothetyAction.java +++ b/src/jdrafting/gui/controller/actions/HomothetyAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; @@ -48,9 +48,8 @@ public void actionPerformed( ActionEvent e ) if ( app.getSelectedShapes().size() > 0 ) { // dialog for homothety factor - JSpinner spinFactor = new JSpinner( - new SpinnerNumberModel( - factor, .1, Double.POSITIVE_INFINITY, .1 ) ); + JSpinner spinFactor = new JSpinner( new SpinnerNumberModel( + factor, 0.1, Double.POSITIVE_INFINITY, 0.1 ) ); spinFactor.addChangeListener( new ChangeListener() { @Override public void stateChanged( ChangeEvent e ) @@ -60,9 +59,9 @@ public void stateChanged( ChangeEvent e ) }); int option = JOptionPane.showOptionDialog( app, spinFactor, - getLocaleText( "homo_dlg" ), - JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, - Application.getLargeIcon( "homothety.png" ), null, null ); + getLocaleText( "homo_dlg" ), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, + getLargeIcon( "homothety.png" ), null, null ); if ( option != JOptionPane.OK_OPTION ) { // back to select mode diff --git a/src/jdrafting/gui/controller/actions/IntersectionsAction.java b/src/jdrafting/gui/controller/actions/IntersectionsAction.java index 4d21ac5..872925f 100644 --- a/src/jdrafting/gui/controller/actions/IntersectionsAction.java +++ b/src/jdrafting/gui/controller/actions/IntersectionsAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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.Color; diff --git a/src/jdrafting/gui/controller/actions/InvertSelectionAction.java b/src/jdrafting/gui/controller/actions/InvertSelectionAction.java index 7e6fc01..544508e 100644 --- a/src/jdrafting/gui/controller/actions/InvertSelectionAction.java +++ b/src/jdrafting/gui/controller/actions/InvertSelectionAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/MediatrixAction.java b/src/jdrafting/gui/controller/actions/MediatrixAction.java index 0d2cc71..2a9029f 100644 --- a/src/jdrafting/gui/controller/actions/MediatrixAction.java +++ b/src/jdrafting/gui/controller/actions/MediatrixAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/MidpointAction.java b/src/jdrafting/gui/controller/actions/MidpointAction.java index f5fa79b..9889471 100644 --- a/src/jdrafting/gui/controller/actions/MidpointAction.java +++ b/src/jdrafting/gui/controller/actions/MidpointAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/ModifySegmentAction.java b/src/jdrafting/gui/controller/actions/ModifySegmentAction.java index c7b11dd..d3f34b4 100644 --- a/src/jdrafting/gui/controller/actions/ModifySegmentAction.java +++ b/src/jdrafting/gui/controller/actions/ModifySegmentAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/MoveZBufferAction.java b/src/jdrafting/gui/controller/actions/MoveZBufferAction.java index 51722bb..28c1e68 100644 --- a/src/jdrafting/gui/controller/actions/MoveZBufferAction.java +++ b/src/jdrafting/gui/controller/actions/MoveZBufferAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/NewAction.java b/src/jdrafting/gui/controller/actions/NewAction.java index 39682fa..0a6aebc 100644 --- a/src/jdrafting/gui/controller/actions/NewAction.java +++ b/src/jdrafting/gui/controller/actions/NewAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/OpenAction.java b/src/jdrafting/gui/controller/actions/OpenAction.java index a49fdd6..29b37b0 100644 --- a/src/jdrafting/gui/controller/actions/OpenAction.java +++ b/src/jdrafting/gui/controller/actions/OpenAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +import static jdrafting.gui.JDUtils.getLargeIcon; +import static jdrafting.gui.JDUtils.getLocaleText; +import static jdrafting.gui.JDUtils.getSmallIcon; import java.awt.Dimension; import java.awt.Graphics; @@ -32,6 +32,7 @@ import jdrafting.Exercise; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; import jdrafting.gui.Viewport; @SuppressWarnings("serial") @@ -62,6 +63,7 @@ public OpenAction( Application app ) accesoryPanel.add( previewPanel ); fileChooser.setAccessory( accesoryPanel ); fileChooser.addPropertyChangeListener( previewPanel ); + fileChooser.setPreferredSize( JDUtils.getScreenSize( 0.7f, 0.7f ) ); } @Override diff --git a/src/jdrafting/gui/controller/actions/ParallelAction.java b/src/jdrafting/gui/controller/actions/ParallelAction.java index e27bffa..4911f11 100644 --- a/src/jdrafting/gui/controller/actions/ParallelAction.java +++ b/src/jdrafting/gui/controller/actions/ParallelAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/PasteStyleAction.java b/src/jdrafting/gui/controller/actions/PasteStyleAction.java index 32ba7ac..b784de7 100644 --- a/src/jdrafting/gui/controller/actions/PasteStyleAction.java +++ b/src/jdrafting/gui/controller/actions/PasteStyleAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/PerpendicularAction.java b/src/jdrafting/gui/controller/actions/PerpendicularAction.java index f5b2256..c382f46 100644 --- a/src/jdrafting/gui/controller/actions/PerpendicularAction.java +++ b/src/jdrafting/gui/controller/actions/PerpendicularAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/PointAction.java b/src/jdrafting/gui/controller/actions/PointAction.java index ecc3235..12f1fa0 100644 --- a/src/jdrafting/gui/controller/actions/PointAction.java +++ b/src/jdrafting/gui/controller/actions/PointAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/PointColorAction.java b/src/jdrafting/gui/controller/actions/PointColorAction.java index 1f8ac10..4801347 100644 --- a/src/jdrafting/gui/controller/actions/PointColorAction.java +++ b/src/jdrafting/gui/controller/actions/PointColorAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; @@ -36,7 +36,7 @@ public PointColorAction( Application app ) jcc = new JColorChooser(); colorChooser = JColorChooser.createDialog( - app, getLocaleText( "point_color_des" ), false, jcc, + app, getLocaleText( "point_color_des" ), true, jcc, (evt) -> app.setPointColor( jcc.getColor() ), // ok null ); // cancel } diff --git a/src/jdrafting/gui/controller/actions/PolyLineAction.java b/src/jdrafting/gui/controller/actions/PolyLineAction.java index 217e2c0..ea308ec 100644 --- a/src/jdrafting/gui/controller/actions/PolyLineAction.java +++ b/src/jdrafting/gui/controller/actions/PolyLineAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/PolygonAction.java b/src/jdrafting/gui/controller/actions/PolygonAction.java index ce4915a..99d1e2c 100644 --- a/src/jdrafting/gui/controller/actions/PolygonAction.java +++ b/src/jdrafting/gui/controller/actions/PolygonAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/ProtractorAction.java b/src/jdrafting/gui/controller/actions/ProtractorAction.java index 1cff97a..88cb455 100644 --- a/src/jdrafting/gui/controller/actions/ProtractorAction.java +++ b/src/jdrafting/gui/controller/actions/ProtractorAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/RectangleAction.java b/src/jdrafting/gui/controller/actions/RectangleAction.java index 2aaaf71..82d34e8 100644 --- a/src/jdrafting/gui/controller/actions/RectangleAction.java +++ b/src/jdrafting/gui/controller/actions/RectangleAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/RedoAction.java b/src/jdrafting/gui/controller/actions/RedoAction.java index ca5c36e..4ad44a0 100644 --- a/src/jdrafting/gui/controller/actions/RedoAction.java +++ b/src/jdrafting/gui/controller/actions/RedoAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/RewindAction.java b/src/jdrafting/gui/controller/actions/RewindAction.java index d5e732c..d5d242e 100644 --- a/src/jdrafting/gui/controller/actions/RewindAction.java +++ b/src/jdrafting/gui/controller/actions/RewindAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/RotationAction.java b/src/jdrafting/gui/controller/actions/RotationAction.java index 268d4a6..97e4cfe 100644 --- a/src/jdrafting/gui/controller/actions/RotationAction.java +++ b/src/jdrafting/gui/controller/actions/RotationAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/RulerAction.java b/src/jdrafting/gui/controller/actions/RulerAction.java index 2c9c8e1..3271b1e 100644 --- a/src/jdrafting/gui/controller/actions/RulerAction.java +++ b/src/jdrafting/gui/controller/actions/RulerAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/SaveAction.java b/src/jdrafting/gui/controller/actions/SaveAction.java index d0f31f5..c284a3b 100644 --- a/src/jdrafting/gui/controller/actions/SaveAction.java +++ b/src/jdrafting/gui/controller/actions/SaveAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; @@ -12,7 +12,6 @@ import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Arrays; -import java.util.stream.Stream; import javax.swing.AbstractAction; import javax.swing.JFileChooser; @@ -22,6 +21,7 @@ import javax.swing.filechooser.FileNameExtensionFilter; import jdrafting.gui.Application; +import jdrafting.gui.JDUtils; /** * Save exercise to media in JDrafting format @@ -71,8 +71,8 @@ public void actionPerformed(ActionEvent e) fileChooser.setSelectedFile( new File( "jd_" + ( counter++ ) + ".jd" ) ); else - fileChooser.setSelectedFile( - new File( camelCase( app.getExercise().getTitle() ) +".jd" ) ); + fileChooser.setSelectedFile( new File( + JDUtils.camelCase( app.getExercise().getTitle() ) +".jd" ) ); String saveFilename = app.getSaveFilename(); @@ -103,22 +103,4 @@ public void actionPerformed(ActionEvent e) app, ex, "Error while saving", JOptionPane.ERROR_MESSAGE ); } } - - /** - * Converts a name to a CamelCase string only with alphanumeric characters - * @param name a name - * @return CamelCase representation - */ - public static String camelCase( String name ) - { - String[] array = name.split( "[^a-zA-Z0-9]" ); - array = Stream.of( array ) - .filter( s -> !s.trim().isEmpty() ) - .map( - s -> Character.toUpperCase( s.charAt( 0 ) ) + s.substring( 1 ) ) - .toArray( String[]::new ); - name = String.join( "", array ); - - return name; - } } diff --git a/src/jdrafting/gui/controller/actions/SaveImageAction.java b/src/jdrafting/gui/controller/actions/SaveImageAction.java index 43c3baf..919ab79 100644 --- a/src/jdrafting/gui/controller/actions/SaveImageAction.java +++ b/src/jdrafting/gui/controller/actions/SaveImageAction.java @@ -3,9 +3,9 @@ import static jdrafting.gui.Application.APPNAME; import static jdrafting.gui.Application.PROJECT_PAGE; import static jdrafting.gui.Application.VERSION; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +import static jdrafting.gui.JDUtils.getLargeIcon; +import static jdrafting.gui.JDUtils.getLocaleText; +import static jdrafting.gui.JDUtils.getSmallIcon; import java.awt.Color; import java.awt.Dimension; @@ -49,6 +49,7 @@ import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; import jdrafting.gui.Viewport; @SuppressWarnings("serial") @@ -75,6 +76,7 @@ public SaveImageAction( Application app ) // create static file chooser dialog fileChooser = new ImageChooser(); + fileChooser.setPreferredSize( JDUtils.getScreenSize( 0.8f, 0.8f ) ); } @Override @@ -101,7 +103,7 @@ public void actionPerformed( ActionEvent e ) fileChooser.setSelectedFile( new File( "jd_" + ( counter++ ) ) ); else fileChooser.setSelectedFile( new File( - SaveAction.camelCase( app.getExercise().getTitle() ) ) ); + JDUtils.camelCase( app.getExercise().getTitle() ) ) ); // set fields fileChooser.textHeight.setText( String.valueOf( getAutomaticHeight( 1000 ) ) ); diff --git a/src/jdrafting/gui/controller/actions/SegmentAction.java b/src/jdrafting/gui/controller/actions/SegmentAction.java index ac55575..0c0dab6 100644 --- a/src/jdrafting/gui/controller/actions/SegmentAction.java +++ b/src/jdrafting/gui/controller/actions/SegmentAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/SelectAllAction.java b/src/jdrafting/gui/controller/actions/SelectAllAction.java index 6cdb945..e2088d2 100644 --- a/src/jdrafting/gui/controller/actions/SelectAllAction.java +++ b/src/jdrafting/gui/controller/actions/SelectAllAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/SelectionAction.java b/src/jdrafting/gui/controller/actions/SelectionAction.java index 097f596..9812367 100644 --- a/src/jdrafting/gui/controller/actions/SelectionAction.java +++ b/src/jdrafting/gui/controller/actions/SelectionAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/ShapeColorAction.java b/src/jdrafting/gui/controller/actions/ShapeColorAction.java index f866d27..0234d26 100644 --- a/src/jdrafting/gui/controller/actions/ShapeColorAction.java +++ b/src/jdrafting/gui/controller/actions/ShapeColorAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; @@ -36,7 +36,7 @@ public ShapeColorAction( Application app ) jcc = new JColorChooser(); colorChooser = JColorChooser.createDialog( - app, getLocaleText( "color_des" ), false, jcc, + app, getLocaleText( "color_des" ), true, jcc, (evt) -> app.setColor( jcc.getColor() ), // ok null ); // cancel } diff --git a/src/jdrafting/gui/controller/actions/SplineAction.java b/src/jdrafting/gui/controller/actions/SplineAction.java index b20e39c..9cba5d6 100644 --- a/src/jdrafting/gui/controller/actions/SplineAction.java +++ b/src/jdrafting/gui/controller/actions/SplineAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/TextVisibleAction.java b/src/jdrafting/gui/controller/actions/TextVisibleAction.java index 988658b..193fb34 100644 --- a/src/jdrafting/gui/controller/actions/TextVisibleAction.java +++ b/src/jdrafting/gui/controller/actions/TextVisibleAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/TranslationAction.java b/src/jdrafting/gui/controller/actions/TranslationAction.java index f8189b6..6babc6c 100644 --- a/src/jdrafting/gui/controller/actions/TranslationAction.java +++ b/src/jdrafting/gui/controller/actions/TranslationAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/UndoAction.java b/src/jdrafting/gui/controller/actions/UndoAction.java index f0c1d4d..1d9479f 100644 --- a/src/jdrafting/gui/controller/actions/UndoAction.java +++ b/src/jdrafting/gui/controller/actions/UndoAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/VertexAction.java b/src/jdrafting/gui/controller/actions/VertexAction.java index dedfe3f..1ceb254 100644 --- a/src/jdrafting/gui/controller/actions/VertexAction.java +++ b/src/jdrafting/gui/controller/actions/VertexAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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; diff --git a/src/jdrafting/gui/controller/actions/ZoomAllAction.java b/src/jdrafting/gui/controller/actions/ZoomAllAction.java index 8408ece..6a80781 100644 --- a/src/jdrafting/gui/controller/actions/ZoomAllAction.java +++ b/src/jdrafting/gui/controller/actions/ZoomAllAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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.KeyEvent; diff --git a/src/jdrafting/gui/controller/actions/ZoomInOutAction.java b/src/jdrafting/gui/controller/actions/ZoomInOutAction.java index b75d0f0..64c0565 100644 --- a/src/jdrafting/gui/controller/actions/ZoomInOutAction.java +++ b/src/jdrafting/gui/controller/actions/ZoomInOutAction.java @@ -1,8 +1,8 @@ package jdrafting.gui.controller.actions; -import static jdrafting.gui.Application.getLargeIcon; -import static jdrafting.gui.Application.getLocaleText; -import static jdrafting.gui.Application.getSmallIcon; +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.KeyEvent; diff --git a/src/jdrafting/gui/controller/mouse/AngleListener.java b/src/jdrafting/gui/controller/mouse/AngleListener.java index 2dda530..81be866 100644 --- a/src/jdrafting/gui/controller/mouse/AngleListener.java +++ b/src/jdrafting/gui/controller/mouse/AngleListener.java @@ -3,7 +3,7 @@ import static jdrafting.geom.JDMath.pointRelativeToCenter; import static jdrafting.geom.JDMath.projection; import static jdrafting.geom.JDMath.vector; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -19,6 +19,7 @@ import jdrafting.geom.JDMath; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Create segment by angle using mouse control @@ -26,7 +27,7 @@ public class AngleListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "angle_cursor.png" ); + JDUtils.getCustomCursor( "angle_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/ArcListener.java b/src/jdrafting/gui/controller/mouse/ArcListener.java index d6e7968..e7abc09 100644 --- a/src/jdrafting/gui/controller/mouse/ArcListener.java +++ b/src/jdrafting/gui/controller/mouse/ArcListener.java @@ -5,7 +5,7 @@ import static jdrafting.geom.JDMath.sumVectors; import static jdrafting.geom.JDMath.vector; import static jdrafting.geom.JDMath.vectorArg; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -21,6 +21,7 @@ import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Creates an arc using mouse control @@ -28,7 +29,7 @@ public class ArcListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "arc_cursor.png" ); + JDUtils.getCustomCursor( "arc_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/ArrowListener.java b/src/jdrafting/gui/controller/mouse/ArrowListener.java index e4299c5..cbbd99d 100644 --- a/src/jdrafting/gui/controller/mouse/ArrowListener.java +++ b/src/jdrafting/gui/controller/mouse/ArrowListener.java @@ -6,7 +6,7 @@ import static jdrafting.geom.JDMath.sumVectors; import static jdrafting.geom.JDMath.vector; import static jdrafting.geom.JDMath.vectorArg; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; @@ -17,6 +17,7 @@ import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Create an arrow using mouse control @@ -24,7 +25,7 @@ public class ArrowListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "arrow_cursor.png" ); + JDUtils.getCustomCursor( "arrow_cursor.png" ); private static final double ANGLE_INTERVAL = PI / 4.; private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/AxialSymmetryListener.java b/src/jdrafting/gui/controller/mouse/AxialSymmetryListener.java index 388e9ff..cb94828 100644 --- a/src/jdrafting/gui/controller/mouse/AxialSymmetryListener.java +++ b/src/jdrafting/gui/controller/mouse/AxialSymmetryListener.java @@ -1,6 +1,6 @@ package jdrafting.gui.controller.mouse; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -24,6 +24,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Axial symmetry of selected shapes using mouse control @@ -31,7 +32,7 @@ public class AxialSymmetryListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "axial_symmetry_cursor.png" ); + JDUtils.getCustomCursor( "axial_symmetry_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/BisectrixListener.java b/src/jdrafting/gui/controller/mouse/BisectrixListener.java index 6c35231..82aa262 100644 --- a/src/jdrafting/gui/controller/mouse/BisectrixListener.java +++ b/src/jdrafting/gui/controller/mouse/BisectrixListener.java @@ -1,11 +1,12 @@ package jdrafting.gui.controller.mouse; import static jdrafting.geom.JDMath.linesIntersection; +import static jdrafting.geom.JDMath.normal; import static jdrafting.geom.JDMath.pointRelativeToCenter; import static jdrafting.geom.JDMath.sumVectors; import static jdrafting.geom.JDMath.vector; -import static jdrafting.geom.JDMath.normal; import static jdrafting.geom.JDMath.vectorArg; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; @@ -21,6 +22,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Create bisectrix segment using mouse control @@ -28,7 +30,7 @@ public class BisectrixListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "bisectrix_cursor.png" ); + JDUtils.getCustomCursor( "bisectrix_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -44,7 +46,7 @@ public BisectrixListener( CanvasPanel canvas ) canvas.setCursor( CURSOR ); - app.setStatusText( Application.getLocaleText( "txt_bisectrix1" ) ); + app.setStatusText( getLocaleText( "txt_bisectrix1" ) ); } @Override @@ -82,8 +84,7 @@ public void mouseReleased( MouseEvent e ) { seg1 = jdshape; canvas.setCursor( CURSOR ); - app.setStatusText( - Application.getLocaleText( "txt_bisectrix2" ) ); + app.setStatusText( getLocaleText( "txt_bisectrix2" ) ); } else return; @@ -101,17 +102,16 @@ else if ( seg2 == null ) { // error message JOptionPane.showMessageDialog( app, - Application.getLocaleText( "bisectrix_dlg" ), - Application.getLocaleText( "bisectrix_title" ), - JOptionPane.ERROR_MESSAGE ); + getLocaleText( "bisectrix_dlg" ), + getLocaleText( "bisectrix_title" ), + JOptionPane.ERROR_MESSAGE ); // back to select mode canvas.setCanvasListener( new HandListener( canvas ) ); return; } canvas.setCursor( CURSOR ); - app.setStatusText( - Application.getLocaleText( "txt_bisectrix3" ) ); + app.setStatusText( getLocaleText( "txt_bisectrix3" ) ); } else return; @@ -120,13 +120,13 @@ else if ( bis1 == null ) { Line2D bisectrix = getBisectrix( logicMouse ); bis1 = bisectrix.getP2(); - app.setStatusText( Application.getLocaleText( "txt_bisectrix4" ) ); + app.setStatusText( getLocaleText( "txt_bisectrix4" ) ); } else { Line2D bisectrix = getBisectrix( logicMouse ); app.addShapeFromIterator( bisectrix.getPathIterator( null ), "", - "> " + Application.getLocaleText( "new_bisectrix" ) + "> " + getLocaleText( "new_bisectrix" ) + " [" + seg1.getName() + "," + seg2.getName() + "]", app.getColor(), app.getStroke() ); diff --git a/src/jdrafting/gui/controller/mouse/BoundsListener.java b/src/jdrafting/gui/controller/mouse/BoundsListener.java index c0b33df..f40323c 100644 --- a/src/jdrafting/gui/controller/mouse/BoundsListener.java +++ b/src/jdrafting/gui/controller/mouse/BoundsListener.java @@ -1,6 +1,6 @@ package jdrafting.gui.controller.mouse; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; @@ -10,6 +10,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Create a rectangle bounds for a shape by mouse control @@ -17,7 +18,7 @@ public class BoundsListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "bounds_cursor.png" ); + JDUtils.getCustomCursor( "bounds_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/CapableArcListener.java b/src/jdrafting/gui/controller/mouse/CapableArcListener.java index 7640b4a..7122ac5 100644 --- a/src/jdrafting/gui/controller/mouse/CapableArcListener.java +++ b/src/jdrafting/gui/controller/mouse/CapableArcListener.java @@ -7,6 +7,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; @@ -21,6 +22,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Create capable arc of a segment using mouse control @@ -28,7 +30,7 @@ public class CapableArcListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "capable_arc_cursor.png" ); + JDUtils.getCustomCursor( "capable_arc_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -43,7 +45,7 @@ public CapableArcListener( CanvasPanel canvas ) canvas.setCursor( CURSOR ); - app.setStatusText( Application.getLocaleText( "txt_cap1" ) ); + app.setStatusText( getLocaleText( "txt_cap1" ) ); } @Override @@ -82,7 +84,7 @@ public void mouseReleased( MouseEvent e ) { segment = jdshape; canvas.setCursor( CURSOR ); - app.setStatusText( Application.getLocaleText( "txt_cap2" ) ); + app.setStatusText( getLocaleText( "txt_cap2" ) ); canvas.repaint(); } } @@ -94,7 +96,7 @@ public void mouseReleased( MouseEvent e ) double flatness = arc.getWidth() / app.getFlatnessValue(); app.addShapeFromIterator( arc.getPathIterator( null, flatness ), "", - "> " + Application.getLocaleText( "new_capable_arc" ) + "> " + getLocaleText( "new_capable_arc" ) + " [" + segment.getName() + "]", app.getColor(), app.getStroke() ); diff --git a/src/jdrafting/gui/controller/mouse/CentralSymmetryListener.java b/src/jdrafting/gui/controller/mouse/CentralSymmetryListener.java index 5826d05..5b0eaf7 100644 --- a/src/jdrafting/gui/controller/mouse/CentralSymmetryListener.java +++ b/src/jdrafting/gui/controller/mouse/CentralSymmetryListener.java @@ -1,7 +1,7 @@ package jdrafting.gui.controller.mouse; import static jdrafting.geom.JDMath.nearInt; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -23,6 +23,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Central symmety on selected shapes using mouse control @@ -30,7 +31,7 @@ public class CentralSymmetryListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "central_symmetry_cursor.png" ); + JDUtils.getCustomCursor( "central_symmetry_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/CircumferenceListener.java b/src/jdrafting/gui/controller/mouse/CircumferenceListener.java index e4221f9..0a65c82 100644 --- a/src/jdrafting/gui/controller/mouse/CircumferenceListener.java +++ b/src/jdrafting/gui/controller/mouse/CircumferenceListener.java @@ -1,6 +1,6 @@ package jdrafting.gui.controller.mouse; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; import java.awt.Graphics2D; @@ -16,11 +16,12 @@ import jdrafting.geom.JDPoint; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class CircumferenceListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "circumference_cursor.png" ); + JDUtils.getCustomCursor( "circumference_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/DivisionPointsListener.java b/src/jdrafting/gui/controller/mouse/DivisionPointsListener.java index a094508..5494562 100644 --- a/src/jdrafting/gui/controller/mouse/DivisionPointsListener.java +++ b/src/jdrafting/gui/controller/mouse/DivisionPointsListener.java @@ -4,7 +4,8 @@ import static jdrafting.geom.JDMath.length; import static jdrafting.geom.JDMath.sumVectors; import static jdrafting.geom.JDMath.vector; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLargeIcon; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -26,11 +27,12 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class DivisionPointsListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "divisions_cursor.png" ); + JDUtils.getCustomCursor( "divisions_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -87,7 +89,7 @@ public void stateChanged( ChangeEvent e ) int option = JOptionPane.showOptionDialog( app, spinDivisions, getLocaleText( "div_dlg" ), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, - Application.getLargeIcon( "divisions.png" ), null, null ); + getLargeIcon( "divisions.png" ), null, null ); if ( option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION ) { diff --git a/src/jdrafting/gui/controller/mouse/EllipseListener.java b/src/jdrafting/gui/controller/mouse/EllipseListener.java index 86ac9ec..ca40ef3 100644 --- a/src/jdrafting/gui/controller/mouse/EllipseListener.java +++ b/src/jdrafting/gui/controller/mouse/EllipseListener.java @@ -1,6 +1,6 @@ package jdrafting.gui.controller.mouse; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; @@ -18,11 +18,12 @@ import jdrafting.geom.JDPoint; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class EllipseListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "ellipse_cursor.png" ); + JDUtils.getCustomCursor( "ellipse_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/ExtremesListener.java b/src/jdrafting/gui/controller/mouse/ExtremesListener.java index 17448ae..3e42ad4 100644 --- a/src/jdrafting/gui/controller/mouse/ExtremesListener.java +++ b/src/jdrafting/gui/controller/mouse/ExtremesListener.java @@ -1,6 +1,6 @@ package jdrafting.gui.controller.mouse; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -18,11 +18,12 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class ExtremesListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "extremes_cursor.png" ); + JDUtils.getCustomCursor( "extremes_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/EyedropperListener.java b/src/jdrafting/gui/controller/mouse/EyedropperListener.java index 4633627..b0ec7a4 100644 --- a/src/jdrafting/gui/controller/mouse/EyedropperListener.java +++ b/src/jdrafting/gui/controller/mouse/EyedropperListener.java @@ -9,11 +9,12 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class EyedropperListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "eyedropper_cursor.png" ); + JDUtils.getCustomCursor( "eyedropper_cursor.png" ); private Application app; private CanvasPanel canvas; @@ -24,7 +25,7 @@ public EyedropperListener( CanvasPanel canvas ) this.canvas = canvas; app = canvas.getApplication(); - app.setStatusText( Application.getLocaleText( "txt_eyedropper" ) ); + app.setStatusText( JDUtils.getLocaleText( "txt_eyedropper" ) ); } @Override diff --git a/src/jdrafting/gui/controller/mouse/FragmentListener.java b/src/jdrafting/gui/controller/mouse/FragmentListener.java index 54303a2..b0d8740 100644 --- a/src/jdrafting/gui/controller/mouse/FragmentListener.java +++ b/src/jdrafting/gui/controller/mouse/FragmentListener.java @@ -1,6 +1,6 @@ package jdrafting.gui.controller.mouse; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -14,11 +14,12 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class FragmentListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "hammer_cursor.png" ); + JDUtils.getCustomCursor( "hammer_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/FreeHandListener.java b/src/jdrafting/gui/controller/mouse/FreeHandListener.java index cfd65c2..62f95c7 100644 --- a/src/jdrafting/gui/controller/mouse/FreeHandListener.java +++ b/src/jdrafting/gui/controller/mouse/FreeHandListener.java @@ -9,13 +9,14 @@ import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class FreeHandListener extends AbstractCanvasMouseListener { private static final Cursor UP_CURSOR = - CanvasPanel.getCustomCursor( "free_hand_up_cursor.png" ); + JDUtils.getCustomCursor( "free_hand_up_cursor.png" ); private static final Cursor DOWN_CURSOR = - CanvasPanel.getCustomCursor( "free_hand_down_cursor.png" ); + JDUtils.getCustomCursor( "free_hand_down_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -33,7 +34,7 @@ public FreeHandListener( CanvasPanel canvas ) canvas.setCursor( UP_CURSOR ); - app.setStatusText( Application.getLocaleText( "txt_free1" ) ); + app.setStatusText( JDUtils.getLocaleText( "txt_free1" ) ); } @Override diff --git a/src/jdrafting/gui/controller/mouse/HandListener.java b/src/jdrafting/gui/controller/mouse/HandListener.java index e5e5227..9187a14 100644 --- a/src/jdrafting/gui/controller/mouse/HandListener.java +++ b/src/jdrafting/gui/controller/mouse/HandListener.java @@ -21,13 +21,14 @@ import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; import jdrafting.gui.EditShapeDialog; +import jdrafting.gui.JDUtils; public class HandListener extends AbstractCanvasMouseListener { private static final Cursor DRAG_CURSOR = - CanvasPanel.getCustomCursor( "dragging_cursor.png" ); + JDUtils.getCustomCursor( "dragging_cursor.png" ); private static final Cursor HAND_CURSOR = - CanvasPanel.getCustomCursor( "hand_cursor.png" ); + JDUtils.getCustomCursor( "hand_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -35,7 +36,7 @@ public class HandListener extends AbstractCanvasMouseListener // drag parameters private int newMouseX, newMouseY; - private boolean moving = false; + public boolean moving = false; private int button = -1; // (mousedragged doesn't keep pressed button) public HandListener( CanvasPanel canvas ) @@ -47,7 +48,7 @@ public HandListener( CanvasPanel canvas ) canvas.setCursor( HAND_CURSOR ); - app.setStatusText( Application.getLocaleText( "txt_hand" ) ); + app.setStatusText( JDUtils.getLocaleText( "txt_hand" ) ); } @Override diff --git a/src/jdrafting/gui/controller/mouse/HomothetyListener.java b/src/jdrafting/gui/controller/mouse/HomothetyListener.java index d921808..009bac6 100644 --- a/src/jdrafting/gui/controller/mouse/HomothetyListener.java +++ b/src/jdrafting/gui/controller/mouse/HomothetyListener.java @@ -1,7 +1,7 @@ package jdrafting.gui.controller.mouse; import static jdrafting.geom.JDMath.nearInt; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -27,6 +27,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Apply homothety to selected shapes using mouse control @@ -34,7 +35,7 @@ public class HomothetyListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "homothety_cursor.png" ); + JDUtils.getCustomCursor( "homothety_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/MediatrixListener.java b/src/jdrafting/gui/controller/mouse/MediatrixListener.java index d8ec988..ddd96e5 100644 --- a/src/jdrafting/gui/controller/mouse/MediatrixListener.java +++ b/src/jdrafting/gui/controller/mouse/MediatrixListener.java @@ -1,6 +1,6 @@ package jdrafting.gui.controller.mouse; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import static jdrafting.geom.JDMath.linesIntersection; import static jdrafting.geom.JDMath.midpoint; import static jdrafting.geom.JDMath.normal; @@ -18,6 +18,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Creates a mediatrix segment using mouse control @@ -25,7 +26,7 @@ public class MediatrixListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "mediatrix_cursor.png" ); + JDUtils.getCustomCursor( "mediatrix_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/MidpointListener.java b/src/jdrafting/gui/controller/mouse/MidpointListener.java index e9b9992..d3cd969 100644 --- a/src/jdrafting/gui/controller/mouse/MidpointListener.java +++ b/src/jdrafting/gui/controller/mouse/MidpointListener.java @@ -1,7 +1,7 @@ package jdrafting.gui.controller.mouse; import static jdrafting.geom.JDMath.centroid; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -15,11 +15,12 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class MidpointListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "midpoint_cursor.png" ); + JDUtils.getCustomCursor( "midpoint_cursor.png" ); private Application app; private CanvasPanel canvas; diff --git a/src/jdrafting/gui/controller/mouse/ModifySegmentListener.java b/src/jdrafting/gui/controller/mouse/ModifySegmentListener.java index 5ae95d8..f95fad9 100644 --- a/src/jdrafting/gui/controller/mouse/ModifySegmentListener.java +++ b/src/jdrafting/gui/controller/mouse/ModifySegmentListener.java @@ -4,7 +4,7 @@ import static jdrafting.geom.JDMath.normal; import static jdrafting.geom.JDMath.sumVectors; import static jdrafting.geom.JDMath.vector; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -20,6 +20,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Modifies a segment using mouse control @@ -27,7 +28,7 @@ public class ModifySegmentListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "modify_segment_cursor.png" ); + JDUtils.getCustomCursor( "modify_segment_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/ParallelListener.java b/src/jdrafting/gui/controller/mouse/ParallelListener.java index ef2f316..3195110 100644 --- a/src/jdrafting/gui/controller/mouse/ParallelListener.java +++ b/src/jdrafting/gui/controller/mouse/ParallelListener.java @@ -6,7 +6,7 @@ import static jdrafting.geom.JDMath.normal; import static jdrafting.geom.JDMath.sumVectors; import static jdrafting.geom.JDMath.vector; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; @@ -19,11 +19,12 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class ParallelListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "parallel_cursor.png" ); + JDUtils.getCustomCursor( "parallel_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/PasteStyleListener.java b/src/jdrafting/gui/controller/mouse/PasteStyleListener.java index fd7e6e1..5cdb62a 100644 --- a/src/jdrafting/gui/controller/mouse/PasteStyleListener.java +++ b/src/jdrafting/gui/controller/mouse/PasteStyleListener.java @@ -13,11 +13,12 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class PasteStyleListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "paste_style_cursor.png" ); + JDUtils.getCustomCursor( "paste_style_cursor.png" ); private Application app; private CanvasPanel canvas; @@ -28,7 +29,7 @@ public PasteStyleListener( CanvasPanel canvas ) this.canvas = canvas; app = canvas.getApplication(); - app.setStatusText( Application.getLocaleText( "txt_paste_style1" ) ); + app.setStatusText( JDUtils.getLocaleText( "txt_paste_style1" ) ); } @Override diff --git a/src/jdrafting/gui/controller/mouse/PerpendicularListener.java b/src/jdrafting/gui/controller/mouse/PerpendicularListener.java index 8398405..e661786 100644 --- a/src/jdrafting/gui/controller/mouse/PerpendicularListener.java +++ b/src/jdrafting/gui/controller/mouse/PerpendicularListener.java @@ -4,7 +4,7 @@ import static jdrafting.geom.JDMath.normal; import static jdrafting.geom.JDMath.sumVectors; import static jdrafting.geom.JDMath.vector; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; @@ -17,6 +17,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Creates a perpendicular segment using mouse control @@ -24,7 +25,7 @@ public class PerpendicularListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "perpendicular_cursor.png" ); + JDUtils.getCustomCursor( "perpendicular_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/PointListener.java b/src/jdrafting/gui/controller/mouse/PointListener.java index 167d5ba..252e3a4 100644 --- a/src/jdrafting/gui/controller/mouse/PointListener.java +++ b/src/jdrafting/gui/controller/mouse/PointListener.java @@ -10,11 +10,12 @@ import jdrafting.geom.JDPoint; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class PointListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "point_cursor.png" ); + JDUtils.getCustomCursor( "point_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -27,7 +28,7 @@ public PointListener( CanvasPanel canvas ) canvas.setCursor( CURSOR ); - app.setStatusText( Application.getLocaleText( "txt_point" ) ); + app.setStatusText( JDUtils.getLocaleText( "txt_point" ) ); } @Override diff --git a/src/jdrafting/gui/controller/mouse/PolygonListener.java b/src/jdrafting/gui/controller/mouse/PolygonListener.java index e9d3cd2..ea7d23e 100644 --- a/src/jdrafting/gui/controller/mouse/PolygonListener.java +++ b/src/jdrafting/gui/controller/mouse/PolygonListener.java @@ -12,6 +12,7 @@ import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Creates a polygon or polyline using mouse control @@ -19,9 +20,9 @@ public class PolygonListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR_POLYGON = - CanvasPanel.getCustomCursor( "polygon_cursor.png" ); + JDUtils.getCustomCursor( "polygon_cursor.png" ); private static final Cursor CURSOR_POLYLINE = - CanvasPanel.getCustomCursor( "polyline_cursor.png" ); + JDUtils.getCustomCursor( "polyline_cursor.png" ); private final Cursor CURSOR; private CanvasPanel canvas; private Application app; @@ -41,7 +42,7 @@ public PolygonListener( CanvasPanel canvas, boolean closed ) CURSOR = closed ? CURSOR_POLYGON : CURSOR_POLYLINE; canvas.setCursor( CURSOR ); - app.setStatusText( Application.getLocaleText( "txt_poly" ) ); + app.setStatusText( JDUtils.getLocaleText( "txt_poly" ) ); } @Override diff --git a/src/jdrafting/gui/controller/mouse/ProtractorListener.java b/src/jdrafting/gui/controller/mouse/ProtractorListener.java index 4eb4792..e4973d0 100644 --- a/src/jdrafting/gui/controller/mouse/ProtractorListener.java +++ b/src/jdrafting/gui/controller/mouse/ProtractorListener.java @@ -1,6 +1,7 @@ package jdrafting.gui.controller.mouse; import static jdrafting.geom.JDMath.lineAng; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -15,6 +16,7 @@ import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Capture an angle using mouse control @@ -22,7 +24,7 @@ public class ProtractorListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "protractor_cursor.png" ); + JDUtils.getCustomCursor( "protractor_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -37,7 +39,7 @@ public ProtractorListener( CanvasPanel canvas ) canvas.setCursor( CURSOR ); - app.setStatusText( Application.getLocaleText( "txt_prot1" ) ); + app.setStatusText( getLocaleText( "txt_prot1" ) ); } @Override @@ -61,13 +63,13 @@ public void mouseReleased( MouseEvent e ) if ( vertex == null ) { vertex = logicMouse; - app.setStatusText( Application.getLocaleText( "txt_prot2" ) ); + app.setStatusText( getLocaleText( "txt_prot2" ) ); } // put first angle side else if ( p1 == null ) { p1 = logicMouse; - app.setStatusText( Application.getLocaleText( "txt_prot3" ) ); + app.setStatusText( getLocaleText( "txt_prot3" ) ); } // put second angle side else diff --git a/src/jdrafting/gui/controller/mouse/RectangleListener.java b/src/jdrafting/gui/controller/mouse/RectangleListener.java index 60d1990..9f9773b 100644 --- a/src/jdrafting/gui/controller/mouse/RectangleListener.java +++ b/src/jdrafting/gui/controller/mouse/RectangleListener.java @@ -1,6 +1,6 @@ package jdrafting.gui.controller.mouse; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; @@ -11,6 +11,7 @@ import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Create a rectangle by mouse control @@ -18,7 +19,7 @@ public class RectangleListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "rectangle_cursor.png" ); + JDUtils.getCustomCursor( "rectangle_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/RotationListener.java b/src/jdrafting/gui/controller/mouse/RotationListener.java index 3b8bb37..dcf17c4 100644 --- a/src/jdrafting/gui/controller/mouse/RotationListener.java +++ b/src/jdrafting/gui/controller/mouse/RotationListener.java @@ -5,7 +5,7 @@ import static java.lang.Math.toDegrees; import static java.lang.Math.toRadians; import static jdrafting.geom.JDMath.nearInt; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -28,6 +28,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Rotate selected shapes using mouse control @@ -35,7 +36,7 @@ public class RotationListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "rotation_cursor.png" ); + JDUtils.getCustomCursor( "rotation_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/RulerListener.java b/src/jdrafting/gui/controller/mouse/RulerListener.java index 2e2ece6..d19b199 100644 --- a/src/jdrafting/gui/controller/mouse/RulerListener.java +++ b/src/jdrafting/gui/controller/mouse/RulerListener.java @@ -1,6 +1,6 @@ package jdrafting.gui.controller.mouse; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; @@ -11,11 +11,12 @@ import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class RulerListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "ruler_cursor.png" ); + JDUtils.getCustomCursor( "ruler_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/SegmentListener.java b/src/jdrafting/gui/controller/mouse/SegmentListener.java index e980e4a..3ab4a27 100644 --- a/src/jdrafting/gui/controller/mouse/SegmentListener.java +++ b/src/jdrafting/gui/controller/mouse/SegmentListener.java @@ -4,7 +4,7 @@ import static jdrafting.geom.JDMath.pointRelativeToCenter; import static jdrafting.geom.JDMath.sumVectors; import static jdrafting.geom.JDMath.vector; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Cursor; @@ -18,6 +18,7 @@ import jdrafting.geom.JDPoint; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Create a segment using mouse control @@ -25,7 +26,7 @@ public class SegmentListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "segment_cursor.png" ); + JDUtils.getCustomCursor( "segment_cursor.png" ); private static final double ANGLE_INTERVAL = Math.PI / 4.; private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/SelectionListener.java b/src/jdrafting/gui/controller/mouse/SelectionListener.java index 3502c21..8628c87 100644 --- a/src/jdrafting/gui/controller/mouse/SelectionListener.java +++ b/src/jdrafting/gui/controller/mouse/SelectionListener.java @@ -14,6 +14,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Rectangular selection by mouse control @@ -36,7 +37,7 @@ public SelectionListener( CanvasPanel canvas ) canvas.setCursor( new Cursor( Cursor.CROSSHAIR_CURSOR ) ); - app.setStatusText( Application.getLocaleText( "txt_sel1" ) ); + app.setStatusText( JDUtils.getLocaleText( "txt_sel1" ) ); } @Override diff --git a/src/jdrafting/gui/controller/mouse/SplineListener.java b/src/jdrafting/gui/controller/mouse/SplineListener.java index 90ee363..70dcdbe 100644 --- a/src/jdrafting/gui/controller/mouse/SplineListener.java +++ b/src/jdrafting/gui/controller/mouse/SplineListener.java @@ -20,6 +20,7 @@ import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Creates a cubic spline using mouse control @@ -27,7 +28,7 @@ public class SplineListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "spline_cursor.png" ); + JDUtils.getCustomCursor( "spline_cursor.png" ); private CanvasPanel canvas; private Application app; @@ -42,7 +43,7 @@ public SplineListener( CanvasPanel canvas ) canvas.setCursor( CURSOR ); - app.setStatusText( Application.getLocaleText( "txt_poly" ) ); + app.setStatusText( JDUtils.getLocaleText( "txt_poly" ) ); } @Override diff --git a/src/jdrafting/gui/controller/mouse/TranslationListener.java b/src/jdrafting/gui/controller/mouse/TranslationListener.java index a4a4387..9f52257 100644 --- a/src/jdrafting/gui/controller/mouse/TranslationListener.java +++ b/src/jdrafting/gui/controller/mouse/TranslationListener.java @@ -3,7 +3,7 @@ import static jdrafting.geom.JDMath.adjustVectorToSize; import static jdrafting.geom.JDMath.sumVectors; import static jdrafting.geom.JDMath.vector; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -26,6 +26,7 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; /** * Translate selected shapes using mouse control @@ -33,7 +34,7 @@ public class TranslationListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "translation_cursor.png" ); + JDUtils.getCustomCursor( "translation_cursor.png" ); private CanvasPanel canvas; private Application app; diff --git a/src/jdrafting/gui/controller/mouse/VertexListener.java b/src/jdrafting/gui/controller/mouse/VertexListener.java index c2a7487..346e158 100644 --- a/src/jdrafting/gui/controller/mouse/VertexListener.java +++ b/src/jdrafting/gui/controller/mouse/VertexListener.java @@ -1,6 +1,6 @@ package jdrafting.gui.controller.mouse; -import static jdrafting.gui.Application.getLocaleText; +import static jdrafting.gui.JDUtils.getLocaleText; import java.awt.BasicStroke; import java.awt.Color; @@ -15,11 +15,12 @@ import jdrafting.geom.JDraftingShape; import jdrafting.gui.Application; import jdrafting.gui.CanvasPanel; +import jdrafting.gui.JDUtils; public class VertexListener extends AbstractCanvasMouseListener { private static final Cursor CURSOR = - CanvasPanel.getCustomCursor( "vertex_cursor.png" ); + 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 393724f..a9ec999 100644 --- a/src/jdrafting/resources/language/language.properties +++ b/src/jdrafting/resources/language/language.properties @@ -1,5 +1,5 @@ // general -app_des=is an open source drafting application to design small Technical Drawing sketches +app_des=is an open-source drafting application to design small Technical Drawing sketches.
This application is inspired by the 'Classical Construction',
also known as 'Ruler-and-compass Construction' or 'Compass-and-straightedge construction'.
However, another drawing tools can be used.
(More info about classical construction: Wikipedia) width=Width height=Height degrees=deg @@ -147,6 +147,8 @@ view=View appearance=Appearance help=Help +item_style=Show/hide style bar +item_ruler_prot=Show/hide ruler&protractor bar item_status=Show/hide status bar item_action=Show/hide action bar item_shape=Show/hide shape bar diff --git a/src/jdrafting/resources/language/language_en.properties b/src/jdrafting/resources/language/language_en.properties index 393724f..a9ec999 100644 --- a/src/jdrafting/resources/language/language_en.properties +++ b/src/jdrafting/resources/language/language_en.properties @@ -1,5 +1,5 @@ // general -app_des=is an open source drafting application to design small Technical Drawing sketches +app_des=is an open-source drafting application to design small Technical Drawing sketches.
This application is inspired by the 'Classical Construction',
also known as 'Ruler-and-compass Construction' or 'Compass-and-straightedge construction'.
However, another drawing tools can be used.
(More info about classical construction: Wikipedia) width=Width height=Height degrees=deg @@ -147,6 +147,8 @@ view=View appearance=Appearance help=Help +item_style=Show/hide style bar +item_ruler_prot=Show/hide ruler&protractor bar item_status=Show/hide status bar item_action=Show/hide action bar item_shape=Show/hide shape bar diff --git a/src/jdrafting/resources/language/language_es.properties b/src/jdrafting/resources/language/language_es.properties index fb3215c..89d8e05 100644 --- a/src/jdrafting/resources/language/language_es.properties +++ b/src/jdrafting/resources/language/language_es.properties @@ -1,5 +1,5 @@ // general -app_des=es una aplicación open source para diseñar pequeños ejercicios de Dibujo Técnico +app_des=es una aplicación open-source para diseñar pequeños ejercicios de Dibujo Técnico.
Esta aplicación está inspirada por la 'Construcción clásica',
también conocida como 'Construcción de regla y compás'.
Sin embargo, otras herramientas de trazado pueden usarse.
(Más info sobre construcción clásica: Wikipedia) width=Ancho height=Alto degrees=grad @@ -147,6 +147,8 @@ view=Vista appearance=Apariencia help=Ayuda +item_style=Mostrar/Ocultar barra de estilo +item_ruler_prot=Mostrar/Ocultar barra de regla y compás item_status=Mostrar/Ocultar barra de estado item_action=Mostrar/Ocultar barra de acciones item_shape=Mostrar/Ocultar barra de figuras