Added super cool properties stuffz
This commit is contained in:
@@ -13,7 +13,7 @@ import java.awt.geom.Rectangle2D;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
|
||||
public class DrawObject {
|
||||
public abstract class DrawObject {
|
||||
Point2D position;
|
||||
double rotation;
|
||||
double scale;
|
||||
@@ -40,6 +40,8 @@ public class DrawObject {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public void draw(Graphics2D g)
|
||||
{
|
||||
AffineTransform tx = getTransform();
|
||||
|
||||
@@ -4,7 +4,6 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Window();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import Listeners.MouseMotion;
|
||||
import Listeners.MouseWheel;
|
||||
import Objects.Entrance;
|
||||
import Objects.Path;
|
||||
import Objects.Podium;
|
||||
import Objects.Stage;
|
||||
import Objects.Toilet;
|
||||
import Objects.Wall;
|
||||
|
||||
@@ -103,7 +103,7 @@ public class Panel extends JPanel {
|
||||
public DrawObject createNewDrawObject(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return new Podium(null);
|
||||
return new Stage(null);
|
||||
case 1:
|
||||
return new Toilet(null);
|
||||
case 2:
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.awt.event.KeyListener;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
@@ -21,11 +22,15 @@ public class PropertiesPanel extends JPanel {
|
||||
|
||||
DrawObject selectedObject = null;
|
||||
Panel p = null;
|
||||
|
||||
Dimension spacerDimension = new Dimension(200,30);
|
||||
|
||||
JLabel nameLabel;
|
||||
JTextField locationXField;
|
||||
JTextField locationYField;
|
||||
JTextField scaleField;
|
||||
JTextField rotationField;
|
||||
|
||||
|
||||
PropertiesPanel() {
|
||||
super();
|
||||
@@ -44,6 +49,18 @@ public class PropertiesPanel extends JPanel {
|
||||
propPanel.setMaximumSize(new Dimension(200, 60));
|
||||
propPanel.add(propLabel);
|
||||
add(propPanel);
|
||||
|
||||
//NAME
|
||||
JPanel namePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
nameLabel = new JLabel("No Selection");
|
||||
nameLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
|
||||
namePanel.setPreferredSize(new Dimension(200, 40));
|
||||
namePanel.setMaximumSize(new Dimension(200, 40));
|
||||
namePanel.add(nameLabel);
|
||||
add(namePanel);
|
||||
|
||||
// SPACER
|
||||
add(Box.createRigidArea(spacerDimension));
|
||||
|
||||
// LOCATION
|
||||
JPanel locationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
@@ -66,7 +83,9 @@ public class PropertiesPanel extends JPanel {
|
||||
locationXField.addKeyListener(new KeyListener() {
|
||||
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
|
||||
public void keyReleased(KeyEvent e) {
|
||||
try {
|
||||
locationXField.setBackground(Color.WHITE);
|
||||
double xpos = Double.parseDouble(locationXField
|
||||
@@ -77,10 +96,6 @@ public class PropertiesPanel extends JPanel {
|
||||
} catch (NumberFormatException nfe) {
|
||||
locationXField.setBackground(Color.RED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void keyReleased(KeyEvent e) {
|
||||
}
|
||||
|
||||
public void keyPressed(KeyEvent e) {
|
||||
@@ -217,11 +232,7 @@ public class PropertiesPanel extends JPanel {
|
||||
}
|
||||
|
||||
// SPACER
|
||||
JPanel spacerPanel = new JPanel();
|
||||
spacerPanel.setPreferredSize(new Dimension(200, 50));
|
||||
spacerPanel.setMaximumSize(new Dimension(200, 50));
|
||||
spacerPanel.setBackground(new Color(220, 220, 220));
|
||||
add(spacerPanel);
|
||||
add(Box.createRigidArea(spacerDimension));
|
||||
|
||||
// EXAMPLE
|
||||
JPanel examplePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
@@ -266,15 +277,18 @@ public class PropertiesPanel extends JPanel {
|
||||
for (Component component : components) {
|
||||
if (component instanceof JTextField) {
|
||||
((JTextField) component).setText("");
|
||||
((JTextField) component).setBackground(Color.WHITE);
|
||||
}
|
||||
if (component instanceof Container) {
|
||||
clearFields((Container) component);
|
||||
}
|
||||
}
|
||||
nameLabel.setText("No Selection");
|
||||
}
|
||||
|
||||
private void fillFields() {
|
||||
if (selectedObject != null) {
|
||||
nameLabel.setText(selectedObject.getName());
|
||||
locationXField.setText(Math.round(selectedObject.getPosition()
|
||||
.getX()) + "");
|
||||
locationYField.setText(Math.round(selectedObject.getPosition()
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Map;
|
||||
|
||||
import Applicatie.DrawObject;
|
||||
import Applicatie.Panel;
|
||||
import Objects.Podium;
|
||||
import Objects.Stage;
|
||||
|
||||
public class Mouse extends MouseAdapter {
|
||||
|
||||
@@ -82,8 +82,8 @@ public class Mouse extends MouseAdapter {
|
||||
}
|
||||
}
|
||||
if (panel.getDragObject() == null && selectedObject != null) {
|
||||
System.out.println("deselected");
|
||||
selectedObject.setSelected(false);
|
||||
panel.getPP().clearSelected();
|
||||
selectedObject = null;
|
||||
}
|
||||
panel.repaint();
|
||||
|
||||
@@ -10,4 +10,9 @@ public class Entrance extends DrawObject {
|
||||
super("images/entrance.png", position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Entrance";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,4 +10,9 @@ public class Path extends DrawObject {
|
||||
super("images/path.jpg", position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Path";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package Objects;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import Applicatie.DrawObject;
|
||||
|
||||
|
||||
public class Stage extends DrawObject {
|
||||
|
||||
public Stage(Point2D position) {
|
||||
super("images/stage3.png", position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Stage";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -10,4 +10,10 @@ public class Toilet extends DrawObject {
|
||||
super("images/wc.png", position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Toilet";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,4 +10,9 @@ public class Wall extends DrawObject {
|
||||
super("images/wall.png", position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Wall";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user