trackeditor: add delete relief point
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8874 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: b820a620e5a0bd925b3951f9b32ad48defb2787f Former-commit-id: 7475b530e1d9d3046066f4ed7c55fa87cf6f5477
This commit is contained in:
parent
8f818602e2
commit
8440fd89dd
4 changed files with 104 additions and 13 deletions
|
@ -1989,7 +1989,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
}
|
||||
|
||||
EditReliefAction editReliefAction = new EditReliefAction("Edit Relief", null, "Edit relief.");
|
||||
|
||||
*/
|
||||
class DeletePointAction extends AbstractAction
|
||||
{
|
||||
public DeletePointAction(String text, ImageIcon icon, String desc)
|
||||
|
@ -1999,15 +1999,25 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
}
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(editorFrame, "Not implemented yet!", "Delete Relief Point", JOptionPane.INFORMATION_MESSAGE);
|
||||
selectedShape = null;
|
||||
invalidate();
|
||||
repaint();
|
||||
Vector<ObjShapeRelief> reliefs = editorFrame.getReliefs().getReliefs();
|
||||
int index = reliefs.indexOf(shape);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
Undo.add(new UndoEditRelief(reliefs, shape));
|
||||
reliefs.get(index).deletePoint2D(mousePoint);
|
||||
reliefs.get(index).calcShape(boundingRectangle);
|
||||
selectedShape = null;
|
||||
invalidate();
|
||||
repaint();
|
||||
editorFrame.documentIsModified = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DeletePointAction deletePointAction = new DeletePointAction("Delete Relief Point", null, "Delete relief point.");
|
||||
*/
|
||||
|
||||
class DeleteReliefAction extends AbstractAction
|
||||
{
|
||||
public DeleteReliefAction(String text, ImageIcon icon, String desc)
|
||||
|
@ -2038,17 +2048,17 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
JPopupMenu menu = new JPopupMenu();
|
||||
// JMenuItem itemEditPoint = new JMenuItem("Edit Point");
|
||||
// JMenuItem itemEditRelief = new JMenuItem("Edit Relief");
|
||||
// JMenuItem itemDeletePoint = new JMenuItem("Delete Point");
|
||||
JMenuItem itemDeletePoint = new JMenuItem("Delete Point");
|
||||
JMenuItem itemDeleteRelief = new JMenuItem("Delete Relief");
|
||||
|
||||
// itemEditPoint.setAction(editPointAction);
|
||||
// itemEditRelief.setAction(editReliefAction);
|
||||
// itemDeletePoint.setAction(deletePointAction);
|
||||
itemDeletePoint.setAction(deletePointAction);
|
||||
itemDeleteRelief.setAction(deleteReliefAction);
|
||||
|
||||
// menu.add(itemEditPoint);
|
||||
// menu.add(itemEditRelief);
|
||||
// menu.add(itemDeletePoint);
|
||||
menu.add(itemDeletePoint);
|
||||
menu.add(itemDeleteRelief);
|
||||
|
||||
menu.addPopupMenuListener(new PopupMenuListener()
|
||||
|
|
|
@ -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.2.4";
|
||||
public final String version = "1.2.5";
|
||||
private String path;
|
||||
|
||||
private double imageScale = 1;
|
||||
|
|
|
@ -44,8 +44,8 @@ public class ObjShapeRelief extends Segment
|
|||
public Object clone()
|
||||
{
|
||||
ObjShapeRelief relief = (ObjShapeRelief) super.clone();
|
||||
relief.reliefType = this.reliefType;
|
||||
relief.lineType = this.lineType;
|
||||
relief.reliefType = reliefType;
|
||||
relief.lineType = lineType;
|
||||
relief.vertices = new Vector<double[]>();
|
||||
for (int i = 0; i < vertices.size(); i++)
|
||||
{
|
||||
|
@ -182,6 +182,25 @@ public class ObjShapeRelief extends Segment
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean deletePoint2D(Point2D.Double point)
|
||||
{
|
||||
if (points == null)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < points.length; i++)
|
||||
{
|
||||
if (points[i].distance(point) <= POINT_RADIUS)
|
||||
{
|
||||
points = null;
|
||||
trPoints = null;
|
||||
vertices.remove(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPoint2D(int index, Point2D.Double point, Rectangle2D.Double boundingRectangle)
|
||||
{
|
||||
if (points == null)
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.awt.event.ActionListener;
|
|||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.Arrays;
|
||||
import java.util.Vector;
|
||||
|
||||
import gui.EditorFrame;
|
||||
|
@ -136,6 +137,12 @@ public class Segment implements Cloneable
|
|||
profilEndTangentLeft = segment.profilEndTangentLeft;
|
||||
profilStartTangentRight = segment.profilStartTangentRight;
|
||||
profilEndTangentRight = segment.profilEndTangentRight;
|
||||
points = Arrays.copyOf(segment.points, segment.points.length);
|
||||
trPoints = Arrays.copyOf(segment.trPoints, segment.trPoints.length);
|
||||
xToDraw = Arrays.copyOf(segment.xToDraw, segment.xToDraw.length);
|
||||
yToDraw = Arrays.copyOf(segment.yToDraw, segment.yToDraw.length);
|
||||
dx = segment.dx;
|
||||
dy = segment.dy;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -727,7 +734,12 @@ public class Segment implements Cloneable
|
|||
s.profilEndTangentLeft = this.profilEndTangentLeft;
|
||||
s.profilStartTangentRight = this.profilStartTangentRight;
|
||||
s.profilEndTangentRight = this.profilEndTangentRight;
|
||||
|
||||
s.points = Arrays.copyOf(points, points.length);
|
||||
s.trPoints = Arrays.copyOf(trPoints, trPoints.length);
|
||||
s.xToDraw = xToDraw.clone();
|
||||
s.yToDraw = yToDraw.clone();
|
||||
s.dx = dx;
|
||||
s.dy = dy;
|
||||
} catch (CloneNotSupportedException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
|
@ -1621,5 +1633,55 @@ public class Segment implements Cloneable
|
|||
System.out.println(indent + " name : " + name);
|
||||
System.out.println(indent + " type : " + type);
|
||||
System.out.println(indent + " count : " + count);
|
||||
if (points != null)
|
||||
{
|
||||
System.out.println(indent + " points : " + points.length);
|
||||
for (int i = 0; i < points.length; i++)
|
||||
{
|
||||
System.out.println(indent + " points[" + i + "] " + points[i].x + ", " + points[i].y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(indent + " points : null");
|
||||
}
|
||||
if (trPoints != null)
|
||||
{
|
||||
System.out.println(indent + " trPoints : " + trPoints.length);
|
||||
for (int i = 0; i < trPoints.length; i++)
|
||||
{
|
||||
System.out.println(indent + " trPoints[" + i + "] " + trPoints[i].x + ", " + trPoints[i].y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(indent + " trPoints : null");
|
||||
}
|
||||
if (xToDraw != null)
|
||||
{
|
||||
System.out.println(indent + " xToDraw : " + xToDraw.length);
|
||||
for (int i = 0; i < xToDraw.length; i++)
|
||||
{
|
||||
System.out.println(indent + " xToDraw[" + i + "] " + xToDraw[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(indent + " xToDraw : null");
|
||||
}
|
||||
if (yToDraw != null)
|
||||
{
|
||||
System.out.println(indent + " yToDraw : " + yToDraw.length);
|
||||
for (int i = 0; i < yToDraw.length; i++)
|
||||
{
|
||||
System.out.println(indent + " yToDraw[" + i + "] " + yToDraw[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(indent + " yToDraw : null");
|
||||
}
|
||||
System.out.println(indent + " dx : " + dx);
|
||||
System.out.println(indent + " dy : " + dy);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue