Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics2D;
- // General element of a graph (nodes and edges)
- abstract public class GraphElement
- {
- // The variables
- private double xPos; // The x-position
- private double yPos;
- protected String label;
- Color defaultColor = Color.BLACK;
- protected final int Width = 100;
- protected final int Height = 30;
- public GraphElement()
- {
- xPos = 0;
- yPos = 0;
- }
- public GraphElement(double x, double y)
- {
- xPos = x;
- yPos = y;
- }
- /**
- Get the x-position of the update
- @return The x-position of the element
- */
- public final double getXPos()
- {
- return xPos;
- }
- /**
- Get the y-position of the update
- @return The y-position of the element
- */
- public final double getYPos()
- {
- return yPos;
- }
- public void moveTo (double xLoc, double yLoc)
- {
- xPos = xLoc;
- yPos = yLoc;
- System.out.println("Did it move?");
- }
- public String toString()
- {
- String str = "(X,Y) Position: (" + xPos + "," + yPos + ")\n";
- return str;
- }
- //Abstract classes to be added by the subclasses
- abstract void draw(Graphics2D g2);
- abstract void setSelected(double x, double y);
- abstract boolean isSelected(double x, double y);;
- abstract double getWidth();
- abstract double getHeight();
- boolean applyLabel()
- {
- return true;
- }
- public String getLabel()
- {
- return label;
- }
- public void setLabel(String label)
- {
- this.label = label;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment