trackeditor: add option to show object and segment names when cursor is on them
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9229 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 35c15a25910222ab69fb7f2e086ab4ec7c3d164e Former-commit-id: 5c610c67dcf993f3de53ac6f8f5800b665b97715
This commit is contained in:
parent
9190e21fb8
commit
f3fa7281de
4 changed files with 97 additions and 5 deletions
|
@ -234,6 +234,8 @@ public class EditorFrame extends JFrame
|
||||||
private final static String INTERACTIVE_FIXES = "InteractiveFixes";
|
private final static String INTERACTIVE_FIXES = "InteractiveFixes";
|
||||||
private boolean cursorCoordinates = false;
|
private boolean cursorCoordinates = false;
|
||||||
private final static String CURSOR_COORDINATES = "CursorCoordinates";
|
private final static String CURSOR_COORDINATES = "CursorCoordinates";
|
||||||
|
private boolean cursorNames = false;
|
||||||
|
private final static String CURSOR_NAMES = "CursorNames";
|
||||||
|
|
||||||
private TrackData trackData = null;
|
private TrackData trackData = null;
|
||||||
private Vector<Surface> defaultSurfaces = new Vector<Surface>();
|
private Vector<Surface> defaultSurfaces = new Vector<Surface>();
|
||||||
|
@ -375,6 +377,7 @@ public class EditorFrame extends JFrame
|
||||||
recentFilesMax = Integer.parseInt(preferences.get(RECENT_FILES_MAX, "10"));
|
recentFilesMax = Integer.parseInt(preferences.get(RECENT_FILES_MAX, "10"));
|
||||||
interactiveFixes = preferences.getBoolean(INTERACTIVE_FIXES, false);
|
interactiveFixes = preferences.getBoolean(INTERACTIVE_FIXES, false);
|
||||||
cursorCoordinates = preferences.getBoolean(CURSOR_COORDINATES, false);
|
cursorCoordinates = preferences.getBoolean(CURSOR_COORDINATES, false);
|
||||||
|
cursorNames = preferences.getBoolean(CURSOR_NAMES, false);
|
||||||
|
|
||||||
if (dataDirectory == null)
|
if (dataDirectory == null)
|
||||||
{
|
{
|
||||||
|
@ -521,6 +524,18 @@ public class EditorFrame extends JFrame
|
||||||
preferences.putBoolean(CURSOR_COORDINATES, cursorCoordinates);
|
preferences.putBoolean(CURSOR_COORDINATES, cursorCoordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getCursorNames()
|
||||||
|
{
|
||||||
|
return cursorNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCursorNames(boolean value)
|
||||||
|
{
|
||||||
|
cursorNames = value;
|
||||||
|
|
||||||
|
preferences.putBoolean(CURSOR_NAMES, cursorNames);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateRecentFiles(String filename)
|
private void updateRecentFiles(String filename)
|
||||||
{
|
{
|
||||||
recentFiles.remove(filename);
|
recentFiles.remove(filename);
|
||||||
|
@ -1359,6 +1374,7 @@ public class EditorFrame extends JFrame
|
||||||
setRecentFilesMax(preferencesDialog.getRecentFilesMax());
|
setRecentFilesMax(preferencesDialog.getRecentFilesMax());
|
||||||
setInteractiveFixes(preferencesDialog.getInteractiveFixes());
|
setInteractiveFixes(preferencesDialog.getInteractiveFixes());
|
||||||
setCursorCoordinates(preferencesDialog.getCursorCoordinates());
|
setCursorCoordinates(preferencesDialog.getCursorCoordinates());
|
||||||
|
setCursorNames(preferencesDialog.getCursorNames());
|
||||||
readDefaultSurfaces();
|
readDefaultSurfaces();
|
||||||
readDefaultObjects();
|
readDefaultObjects();
|
||||||
view.redrawCircuit();
|
view.redrawCircuit();
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class PreferencesDialog extends JDialog
|
||||||
private JTextField recentFilesMaxTextField = null;
|
private JTextField recentFilesMaxTextField = null;
|
||||||
private JCheckBox interactiveFixesCheckBox = null;
|
private JCheckBox interactiveFixesCheckBox = null;
|
||||||
private JCheckBox cursorCoordinatesCheckBox = null;
|
private JCheckBox cursorCoordinatesCheckBox = null;
|
||||||
|
private JCheckBox cursorNamesCheckBox = null;
|
||||||
private JButton okButton = null;
|
private JButton okButton = null;
|
||||||
private JButton cancelButton = null;
|
private JButton cancelButton = null;
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ public class PreferencesDialog extends JDialog
|
||||||
|
|
||||||
private void initialize()
|
private void initialize()
|
||||||
{
|
{
|
||||||
this.setSize(600, 285);
|
this.setSize(600, 307); //285);
|
||||||
this.setContentPane(getJPanel());
|
this.setContentPane(getJPanel());
|
||||||
this.setModal(true);
|
this.setModal(true);
|
||||||
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
@ -96,6 +97,7 @@ public class PreferencesDialog extends JDialog
|
||||||
jPanel.add(getRecentFilesMaxTextField(), null);
|
jPanel.add(getRecentFilesMaxTextField(), null);
|
||||||
jPanel.add(getInteractiveFixesCheckBox(), null);
|
jPanel.add(getInteractiveFixesCheckBox(), null);
|
||||||
jPanel.add(getCursorCoordinatesCheckBox(), null);
|
jPanel.add(getCursorCoordinatesCheckBox(), null);
|
||||||
|
jPanel.add(getCursorNamesCheckBox(), null);
|
||||||
jPanel.add(getOkButton(), null);
|
jPanel.add(getOkButton(), null);
|
||||||
jPanel.add(getCancelButton(), null);
|
jPanel.add(getCancelButton(), null);
|
||||||
}
|
}
|
||||||
|
@ -287,12 +289,24 @@ public class PreferencesDialog extends JDialog
|
||||||
return cursorCoordinatesCheckBox;
|
return cursorCoordinatesCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JCheckBox getCursorNamesCheckBox()
|
||||||
|
{
|
||||||
|
if (cursorNamesCheckBox == null)
|
||||||
|
{
|
||||||
|
cursorNamesCheckBox = new JCheckBox();
|
||||||
|
cursorNamesCheckBox.setBounds(200, 183, 290, 23);
|
||||||
|
cursorNamesCheckBox.setText("Cursor Names");
|
||||||
|
cursorNamesCheckBox.setSelected(editorFrame.getCursorNames());
|
||||||
|
}
|
||||||
|
return cursorNamesCheckBox;
|
||||||
|
}
|
||||||
|
|
||||||
private JButton getOkButton()
|
private JButton getOkButton()
|
||||||
{
|
{
|
||||||
if (okButton == null)
|
if (okButton == null)
|
||||||
{
|
{
|
||||||
okButton = new JButton();
|
okButton = new JButton();
|
||||||
okButton.setBounds(160, 210, 78, 25);
|
okButton.setBounds(160, 232, 78, 25);
|
||||||
okButton.setText("Ok");
|
okButton.setText("Ok");
|
||||||
okButton.addActionListener(new ActionListener()
|
okButton.addActionListener(new ActionListener()
|
||||||
{
|
{
|
||||||
|
@ -310,7 +324,7 @@ public class PreferencesDialog extends JDialog
|
||||||
if (cancelButton == null)
|
if (cancelButton == null)
|
||||||
{
|
{
|
||||||
cancelButton = new JButton();
|
cancelButton = new JButton();
|
||||||
cancelButton.setBounds(350, 210, 78, 25);
|
cancelButton.setBounds(350, 232, 78, 25);
|
||||||
cancelButton.setText("Cancel");
|
cancelButton.setText("Cancel");
|
||||||
cancelButton.addActionListener(new ActionListener()
|
cancelButton.addActionListener(new ActionListener()
|
||||||
{
|
{
|
||||||
|
@ -375,6 +389,11 @@ public class PreferencesDialog extends JDialog
|
||||||
return getCursorCoordinatesCheckBox().isSelected();
|
return getCursorCoordinatesCheckBox().isSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getCursorNames()
|
||||||
|
{
|
||||||
|
return getCursorNamesCheckBox().isSelected();
|
||||||
|
}
|
||||||
|
|
||||||
protected void processWindowEvent(WindowEvent e)
|
protected void processWindowEvent(WindowEvent e)
|
||||||
{
|
{
|
||||||
super.processWindowEvent(e);
|
super.processWindowEvent(e);
|
||||||
|
|
|
@ -137,6 +137,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
||||||
private ObjShapeObject objectShape = null;
|
private ObjShapeObject objectShape = null;
|
||||||
/** offset between mouse click position and object position */
|
/** offset between mouse click position and object position */
|
||||||
private Point2D.Double objectOffset = new Point2D.Double();
|
private Point2D.Double objectOffset = new Point2D.Double();
|
||||||
|
private String objectName = null;
|
||||||
|
|
||||||
private ObjShapeRelief reliefShape = null;
|
private ObjShapeRelief reliefShape = null;
|
||||||
private int reliefPointIndex = 0;
|
private int reliefPointIndex = 0;
|
||||||
|
@ -1046,6 +1047,28 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
||||||
{
|
{
|
||||||
case STATE_NONE :
|
case STATE_NONE :
|
||||||
{
|
{
|
||||||
|
// must check for a object under the mouse
|
||||||
|
Segment obj = findObjAtMousePos();
|
||||||
|
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
if (obj.getType().equals("graphic object") ||
|
||||||
|
obj.getType().equals("object") ||
|
||||||
|
obj.getType().equals("rgt") ||
|
||||||
|
obj.getType().equals("lft") ||
|
||||||
|
obj.getType().equals("str"))
|
||||||
|
{
|
||||||
|
objectName = new String(obj.getName());
|
||||||
|
invalidate();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (objectName != null)
|
||||||
|
{
|
||||||
|
objectName = null;
|
||||||
|
invalidate();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1134,6 +1157,32 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
||||||
invalidate();
|
invalidate();
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (editorFrame.getCursorNames())
|
||||||
|
{
|
||||||
|
// must check for a object under the mouse
|
||||||
|
Segment obj = findObjAtMousePos();
|
||||||
|
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
if (obj.getType().equals("graphic object") ||
|
||||||
|
obj.getType().equals("object") ||
|
||||||
|
obj.getType().equals("rgt") ||
|
||||||
|
obj.getType().equals("lft") ||
|
||||||
|
obj.getType().equals("str"))
|
||||||
|
{
|
||||||
|
objectName = new String(obj.getName());
|
||||||
|
invalidate();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (objectName != null)
|
||||||
|
{
|
||||||
|
objectName = null;
|
||||||
|
invalidate();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /** input events management */
|
// /** input events management */
|
||||||
|
@ -1588,6 +1637,14 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (editorFrame.getCursorNames())
|
||||||
|
{
|
||||||
|
if (objectName != null)
|
||||||
|
{
|
||||||
|
graphics.drawString(objectName, r.x + 10, r.y + 40);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (editorFrame.getTrackData() != null && editorFrame.getTrackData().getSegments() != null)
|
if (editorFrame.getTrackData() != null && editorFrame.getTrackData().getSegments() != null)
|
||||||
{
|
{
|
||||||
if (boundingRectangle == null)
|
if (boundingRectangle == null)
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class Properties
|
||||||
private static Properties instance = new Properties();
|
private static Properties instance = new Properties();
|
||||||
private Vector<ActionListener> propertiesListeners = new Vector<ActionListener>();
|
private Vector<ActionListener> propertiesListeners = new Vector<ActionListener>();
|
||||||
public final String title = "sd2-trackeditor";
|
public final String title = "sd2-trackeditor";
|
||||||
public final String version = "1.3.28";
|
public final String version = "1.3.29";
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
private double imageScale = 1;
|
private double imageScale = 1;
|
||||||
|
|
Loading…
Reference in a new issue