001: package tools.tracesviewer;
002:
003: import java.awt.*;
004:
005: /**
006: *@version 1.2
007: *
008: *@author Olivier Deruelle <br/>
009: *
010: *
011: */
012:
013: abstract class Arrow {
014:
015: public String arrowName;
016: public TracesMessage tracesMessage;
017: public TracesCanvas tracesCanvas;
018:
019: public boolean visible = true;
020: public boolean selected;
021:
022: public Color color;
023:
024: public int xmin;
025: public int xmax;
026: public int ymin;
027: public int ymax;
028:
029: public boolean statusInfo = false;
030: public boolean displayInfo = false;
031: public boolean displayTipTool = false;
032:
033: abstract int xmin();
034:
035: abstract int xmax();
036:
037: abstract int ymin();
038:
039: abstract int ymax();
040:
041: public int xminInfo;
042: public int xmaxInfo;
043: public int yminInfo;
044: public int ymaxInfo;
045:
046: abstract void draw(Graphics g);
047:
048: public void setColor(Color color) {
049: this .color = color;
050: }
051:
052: public void setTracesMessage(TracesMessage tracesMessage) {
053: this .tracesMessage = tracesMessage;
054: }
055:
056: public TracesMessage getTracesMessage() {
057: return tracesMessage;
058: }
059:
060: public void setTracesCanvas(TracesCanvas tracesCanvas) {
061: this .tracesCanvas = tracesCanvas;
062: }
063:
064: public Arrow(boolean selected, String arrowName, boolean flag,
065: int xmin, int xmax, int ymin, int ymax, boolean info) {
066: this .arrowName = arrowName;
067: this .xmin = xmin;
068: this .xmax = xmax;
069: this .ymin = ymin;
070: this .ymax = ymax;
071: this .selected = selected;
072: visible = flag;
073: statusInfo = info;
074: }
075:
076: public boolean isCollisionArrow(int x, int y) {
077: // Return true if the cursor is inside the rectangle delimited by
078: // the arrow:
079: //System.out.println("isCollision: xmin:"+xmin+" xmax:"+xmax+" ymin:"+ymin+" ymax:"+ymax);
080: // We have to be careful to the negative distance:
081: if (xmin <= xmax) {
082: if (x < xmax && x > xmin)
083: if (y < ymax && y > ymin)
084: return true;
085: else
086: return false;
087: else
088: return false;
089: } else {
090: if (x < xmin && x > xmax)
091: if (y < ymax && y > ymin)
092: return true;
093: else
094: return false;
095: else
096: return false;
097: }
098: }
099:
100: public boolean isCollisionInfo(int x, int y) {
101: // Return true if the cursor is inside the rectangle delimited by
102: // the info:
103: //System.out.println("isCollision x:"+x+" y:"+y+" xminInfo:"+xminInfo+" xmaxInfo:"+xmaxInfo+
104: // " yminInfo:"+yminInfo+" ymaxInfo:"+ymaxInfo);
105: // We have to be careful to the negative distance:
106: if (x < xmaxInfo && x > xminInfo)
107: if (y < ymaxInfo && y > yminInfo)
108: return true;
109: else
110: return false;
111: else
112: return false;
113: }
114:
115: }
|