source: src/main/java/negotiator/onetomany/etc/Shape.java@ 222

Last change on this file since 222 was 212, checked in by Faria Nassiri Mofakham, 6 years ago
File size: 1.2 KB
Line 
1/**
2 *
3 */
4package negotiator.onetomany.etc;
5
6import java.awt.Color;
7import java.awt.Graphics;
8import java.awt.Point;
9
10//import javax.swing.*;
11//import java.awt.*;
12
13/**
14 * @author Faria Nassiri-Mofakham
15 *
16 */
17public abstract class Shape {
18
19 /**
20 *
21 */
22 protected Point location;
23 protected int dimension;
24 protected Color color;
25
26
27 public Color getColor() {
28 return color;
29 }
30
31 public void setColor(Color color) {
32 this.color = color;
33 }
34
35 public int getDimension() {
36 return dimension;
37 }
38
39 public void setDimensions(int dim) {
40 this.dimension = dim;
41 }
42
43 public Shape(Point loc, int dim, Color col)
44 {
45 setLocation(loc);
46 setDimensions(dim);
47 setColor(col);
48 }
49
50 public Point getLocation() {
51 return location;
52 }
53
54 public void setLocation(Point loc)
55 {
56 this.location = loc;
57 }
58
59 public void paint(Graphics g, Color c)
60 {
61 g.setColor(c);
62 draw(g);
63 }
64
65 public void draw(Graphics g)
66 {
67 int xLocation = this.getLocation().x;
68 int yLocation = this.getLocation().y;
69 int[] xValues = {xLocation, xLocation, xLocation+getDimension()};
70 int[] yValues = {yLocation, yLocation, yLocation+getDimension()};
71 g.fillPolygon(xValues, yValues, 31); //31 points
72 }
73}
Note: See TracBrowser for help on using the repository browser.