trackeditor: add ability to move objects in object map property page to graphics
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9080 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 057b3a69d7ba1321871b153b7b37b88e9b429772 Former-commit-id: 32aa3664f363b0a4d2b3b75dc0e85202639657e1
This commit is contained in:
parent
de8ce3f197
commit
391c167d62
7 changed files with 116 additions and 31 deletions
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
package gui;
|
||||
|
||||
import gui.properties.GraphicObjectProperties;
|
||||
import gui.properties.PropertiesDialog;
|
||||
import gui.splash.SplashScreen;
|
||||
import gui.view.CircuitView;
|
||||
|
@ -254,6 +255,16 @@ public class EditorFrame extends JFrame
|
|||
private int currentObjectColor = 0;
|
||||
private boolean currentObjectGraphic = false;
|
||||
|
||||
private GraphicObjectProperties graphicObjectProperties = null;
|
||||
|
||||
public GraphicObjectProperties getGraphicObjectProperties() {
|
||||
return graphicObjectProperties;
|
||||
}
|
||||
|
||||
public void setGraphicObjectProperties(GraphicObjectProperties graphicObjectProperties) {
|
||||
this.graphicObjectProperties = graphicObjectProperties;
|
||||
}
|
||||
|
||||
public boolean isPasteObject() {
|
||||
return pasteObject;
|
||||
}
|
||||
|
|
19
src/tools/trackeditor/gui/properties/GraphicObjectData.java
Normal file
19
src/tools/trackeditor/gui/properties/GraphicObjectData.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package gui.properties;
|
||||
|
||||
public class GraphicObjectData
|
||||
{
|
||||
String name;
|
||||
Integer color;
|
||||
Double trackX;
|
||||
Double trackY;
|
||||
Double orientation;
|
||||
|
||||
GraphicObjectData(String name, Integer color, double trackX, double trackY, double orientation)
|
||||
{
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
this.trackX = trackX;
|
||||
this.trackY = trackY;
|
||||
this.orientation = orientation;
|
||||
}
|
||||
}
|
|
@ -33,8 +33,9 @@ import utils.circuit.GraphicObject;
|
|||
|
||||
public class GraphicObjectProperties extends PropertyPanel
|
||||
{
|
||||
private GraphicObjectTablePanel graphicObjectTablePanel = null;
|
||||
private Vector<GraphicObject> graphicObjects = null;
|
||||
private GraphicObjectTablePanel graphicObjectTablePanel = null;
|
||||
private Vector<GraphicObject> graphicObjects = null;
|
||||
private Vector<GraphicObjectData> data = new Vector<GraphicObjectData>();
|
||||
|
||||
public GraphicObjectProperties(EditorFrame editorFrame)
|
||||
{
|
||||
|
@ -47,32 +48,18 @@ public class GraphicObjectProperties extends PropertyPanel
|
|||
setLayout(null);
|
||||
graphicObjects = getEditorFrame().getGraphicObjects();
|
||||
add(getGraphicObjectTablePanel(), null);
|
||||
getEditorFrame().setGraphicObjectProperties(this);
|
||||
}
|
||||
|
||||
public class Data
|
||||
{
|
||||
String name;
|
||||
Integer color;
|
||||
Double trackX;
|
||||
Double trackY;
|
||||
Double orientation;
|
||||
|
||||
Data(String name, Integer color, double trackX, double trackY, double orientation)
|
||||
{
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
this.trackX = trackX;
|
||||
this.trackY = trackY;
|
||||
this.orientation = orientation;
|
||||
}
|
||||
}
|
||||
|
||||
private Vector<Data> data = new Vector<Data>();
|
||||
|
||||
public Vector<Data> getData()
|
||||
public Vector<GraphicObjectData> getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public void addData(GraphicObjectData graphicObjectData)
|
||||
{
|
||||
graphicObjectTablePanel.model.addRow(graphicObjectData);
|
||||
}
|
||||
|
||||
private GraphicObjectTablePanel getGraphicObjectTablePanel()
|
||||
{
|
||||
|
@ -147,7 +134,7 @@ public class GraphicObjectProperties extends PropertyPanel
|
|||
name = new String("Unknown");
|
||||
}
|
||||
|
||||
data.add(new Data(name, object.getColor(), object.getX(), object.getY(), object.getOrientation()));
|
||||
data.add(new GraphicObjectData(name, object.getColor(), object.getX(), object.getY(), object.getOrientation()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,7 +184,7 @@ public class GraphicObjectProperties extends PropertyPanel
|
|||
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
Data datum = data.get(rowIndex);
|
||||
GraphicObjectData datum = data.get(rowIndex);
|
||||
|
||||
switch (columnIndex)
|
||||
{
|
||||
|
@ -225,7 +212,7 @@ public class GraphicObjectProperties extends PropertyPanel
|
|||
|
||||
public void setValueAt(Object value, int rowIndex, int columnIndex)
|
||||
{
|
||||
Data datum = data.get(rowIndex);
|
||||
GraphicObjectData datum = data.get(rowIndex);
|
||||
|
||||
switch (columnIndex)
|
||||
{
|
||||
|
@ -269,6 +256,12 @@ public class GraphicObjectProperties extends PropertyPanel
|
|||
data.removeElementAt(row);
|
||||
fireTableRowsDeleted(row - 1, data.size() - 1);
|
||||
}
|
||||
|
||||
public void addRow(GraphicObjectData graphicObjectData)
|
||||
{
|
||||
data.add(graphicObjectData);
|
||||
fireTableRowsInserted(data.size() - 1, data.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void setUpNameColumn(JTable table, TableColumn nameColumn, Set<String> names)
|
||||
|
@ -418,7 +411,7 @@ public class GraphicObjectProperties extends PropertyPanel
|
|||
}
|
||||
for (int j = 0; j < minDataCount; j++)
|
||||
{
|
||||
Data datum = data.get(j);
|
||||
GraphicObjectData datum = data.get(j);
|
||||
GraphicObject object = graphicObjects.get(j);
|
||||
|
||||
if (!datum.name.equals(object.getName()))
|
||||
|
@ -473,7 +466,7 @@ public class GraphicObjectProperties extends PropertyPanel
|
|||
// need to add to objects
|
||||
while (graphicObjects.size() < data.size())
|
||||
{
|
||||
Data datum = data.get(graphicObjects.size());
|
||||
GraphicObjectData datum = data.get(graphicObjects.size());
|
||||
|
||||
graphicObjects.add(new GraphicObject(datum.name, datum.color, new Point2D.Double(datum.trackX, datum.trackY)));
|
||||
|
||||
|
|
|
@ -663,8 +663,10 @@ public class ObjectMapProperties extends PropertyPanel
|
|||
JMenuItem deleteItem = new JMenuItem("Delete Object");
|
||||
JMenuItem deleteAllColorItem = new JMenuItem("Delete All Objects With This Color");
|
||||
JMenuItem deleteAllNameItem = new JMenuItem("Delete All Objects With This Name");
|
||||
JMenuItem moveToObjects = new JMenuItem("Move To Objects");
|
||||
JMenuItem moveAllToObjects = new JMenuItem("Move All To Objects");
|
||||
|
||||
deleteItem.addActionListener(new ActionListener()
|
||||
deleteItem.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
|
@ -748,10 +750,70 @@ public class ObjectMapProperties extends PropertyPanel
|
|||
}
|
||||
}
|
||||
});
|
||||
moveToObjects.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
int row = panel.table.getSelectedRow();
|
||||
if (row != -1)
|
||||
{
|
||||
if (JOptionPane.showConfirmDialog(null, "Move this object?", "Move Object", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
||||
{
|
||||
Data datum = data.elementAt(panel.table.convertRowIndexToModel(row));
|
||||
String name = getEditorFrame().getObjectColorName(datum.color) + "-" + data.size();
|
||||
GraphicObjectData graphicObjectData = new GraphicObjectData(name, datum.color, datum.trackX, datum.trackY, Double.NaN);
|
||||
getEditorFrame().getGraphicObjectProperties().addData(graphicObjectData);
|
||||
panel.model.removeRowAt(panel.table.convertRowIndexToModel(row));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
moveAllToObjects.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
int row = panel.table.getSelectedRow();
|
||||
if (row != -1)
|
||||
{
|
||||
if (JOptionPane.showConfirmDialog(null, "Move all objects with this name?", "Move Objects with Name", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
||||
{
|
||||
Data datum = data.elementAt(panel.table.convertRowIndexToModel(row));
|
||||
Vector<Integer> toDelete = new Vector<Integer>();
|
||||
for (int i = 0; i < data.size(); i++)
|
||||
{
|
||||
if (datum.name.equals(data.elementAt(i).name))
|
||||
{
|
||||
toDelete.add(i);
|
||||
}
|
||||
}
|
||||
Collections.sort(toDelete, new Comparator<Integer>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Integer o1, Integer o2)
|
||||
{
|
||||
// Changing the order of the elements
|
||||
return o2 - o1;
|
||||
}
|
||||
});
|
||||
int size = data.size();
|
||||
for (int i = 0; i < toDelete.size(); i++)
|
||||
{
|
||||
Data datum1 = data.elementAt(panel.table.convertRowIndexToModel(row));
|
||||
String name = getEditorFrame().getObjectColorName(datum.color) + "-" + size++;
|
||||
GraphicObjectData graphicObjectData = new GraphicObjectData(name, datum.color, datum1.trackX, datum1.trackY, Double.NaN);
|
||||
getEditorFrame().getGraphicObjectProperties().addData(graphicObjectData);
|
||||
panel.model.removeRowAt(toDelete.elementAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
popupMenu.add(deleteItem);
|
||||
popupMenu.add(deleteAllColorItem);
|
||||
popupMenu.add(deleteAllNameItem);
|
||||
popupMenu.add(moveToObjects);
|
||||
popupMenu.add(moveAllToObjects);
|
||||
|
||||
return popupMenu;
|
||||
}
|
||||
|
|
|
@ -414,6 +414,7 @@ public class PropertiesDialog extends JDialog
|
|||
*/
|
||||
protected void cancel()
|
||||
{
|
||||
editorFrame.setGraphicObjectProperties(null);
|
||||
editorFrame.getProject().setPropertiesEditorX(this.getX());
|
||||
editorFrame.getProject().setPropertiesEditorY(this.getY());
|
||||
editorFrame.getProject().setPropertiesEditorTab(this.tabbedPane.getSelectedIndex());
|
||||
|
|
|
@ -72,7 +72,6 @@ import utils.undo.UndoEditAllObjects;
|
|||
import utils.undo.UndoEditGraphicObject;
|
||||
import utils.undo.UndoEditObject;
|
||||
import utils.undo.UndoEditRelief;
|
||||
import utils.undo.UndoMoveGraphicObject;
|
||||
import utils.undo.UndoSegmentChange;
|
||||
import utils.undo.UndoSplitSegment;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public class Properties
|
|||
private static Properties instance = new Properties();
|
||||
private Vector<ActionListener> propertiesListeners = new Vector<ActionListener>();
|
||||
public final String title = "sd2-trackeditor";
|
||||
public final String version = "1.3.0";
|
||||
public final String version = "1.3.1";
|
||||
private String path;
|
||||
|
||||
private double imageScale = 1;
|
||||
|
|
Loading…
Reference in a new issue