Ignore:
Timestamp:
01/07/09 13:25:13 (15 years ago)
Author:
ra33
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Dot.java

    r376 r427  
    2626        // Standard Item variables
    2727
    28         //private static final int _MINIMUM_DOT_SIZE = 6;
     28        // private static final int _MINIMUM_DOT_SIZE = 6;
    2929
    3030        private static final int MINIMUM_DOT_SIZE = 2;
    31 
    32         private int _pointType = Item.POINTTYPE_SQUARE;
    33 
    34         private boolean _filled = true;
    3531
    3632        public Dot(int id) {
     
    5551        }
    5652
    57         public void setPointType(int type) {
    58                 _pointType = type;
    59         }
    60 
    61         public void useFilledPoints(boolean val) {
    62                 _filled = val;
    63         }
    64 
    6553        @Override
    6654        public void setColor(Color c) {
     
    116104                        Color highlightColor = getHighlightColor();
    117105                        g.setColor(highlightColor);
    118                         g.setStroke(HIGHLIGHT_STROKE);
     106                        g.setStroke(DOT_STROKE);
    119107                        // g.setStroke()
    120108                        // Draw the highlighting rectangle surrounding the dot
    121109                        // this is drawn even if its part of a rectangle
    122                        
    123                         if(isVectorItem())
     110
     111                        if (isVectorItem())
    124112                                updatePolygon();
    125                        
     113
    126114                        Rectangle rect = getPolygon().getBounds();
    127115                        if (_mode == HighlightMode.Enclosed ||
     
    129117                                        this.getConnected().size() <= 1)
    130118                                g.fillRect(rect.x, rect.y, rect.width, rect.height);
    131                         else if (_mode == HighlightMode.Connected)
     119                        else if (_mode == HighlightMode.Connected){
     120                                g.setStroke(HIGHLIGHT_STROKE);
    132121                                g.drawRect(rect.x, rect.y, rect.width, rect.height);
    133                         else if (_mode == HighlightMode.Normal) {
     122                        }else if (_mode == HighlightMode.Normal) {
    134123                                g.fillOval(rect.x, rect.y, rect.width, rect.height);
    135124                        }
     
    149138                int width = thick / 2;
    150139
    151                 if (_pointType == Item.POINTTYPE_CIRCLE) {
    152                         int points = 40;
    153 
    154                         double radians = 0.0;
    155                         int xPoints[] = new int[points];
    156                         int yPoints[] = new int[xPoints.length];
    157 
    158                         for (int i = 0; i < xPoints.length; i++) {
    159                                 xPoints[i] = getX() + (int) (width * Math.cos(radians));
    160                                 yPoints[i] = getY() + (int) (width * Math.sin(radians));
    161                                 radians += (2.0 * Math.PI) / xPoints.length;
    162                         }
    163 
    164                         if (_filled)
    165                                 g.fillPolygon(new Polygon(xPoints, yPoints, xPoints.length));
    166                         else
    167                                 g.drawPolygon(new Polygon(xPoints, yPoints, xPoints.length));
    168                 } else {
     140                switch (_type) {
     141                case circle:
     142                        if (_filled)
     143                                g.fillOval(getX() - width, getY() - width, thick, thick);
     144                        else {
     145                                g.drawOval(getX() - width, getY() - width, thick, thick);
     146                        }
     147                        break;
     148                case diamond:
     149                        int[] x = new int[4];
     150                        int[] y = new int[4];
     151
     152                        x[0] = x[2] = getX();
     153                        x[1] = getX() - width;
     154                        x[3] = getX() + width;
     155
     156                        y[1] = y[3] = getY();
     157                        y[0] = getY() - width;
     158                        y[2] = getY() + width;
     159
     160                        if (_filled)
     161                                g.fillPolygon(x, y, 4);
     162                        else {
     163                                g.drawPolygon(x, y, 4);
     164                        }
     165                        break;
     166                case triangle:
     167                        x = new int[3];
     168                        y = new int[3];
     169
     170                        x[0] = getX();
     171                        x[1] = getX() - width;
     172                        x[2] = getX() + width;
     173
     174                        y[0] = getY() - width;
     175                        y[1] = y[2] = getY() + width;
     176
     177                        if (_filled)
     178                                g.fillPolygon(x, y, 3);
     179                        else {
     180                                g.drawPolygon(x, y, 3);
     181                        }
     182                        break;
     183                case roundSquare:
     184                        int arc = thick / 2;
     185                        if (_filled)
     186                                g.fillRoundRect(getX() - width, getY() - width, thick, thick,
     187                                                arc, arc);
     188                        else {
     189                                g.drawRoundRect(getX() - width, getY() - width, thick, thick,
     190                                                arc, arc);
     191                        }
     192                        break;
     193                default:
    169194                        if (_filled)
    170195                                g.fillRect(getX() - width, getY() - width, thick, thick);
    171                         else
     196                        else {
    172197                                g.drawRect(getX() - width, getY() - width, thick, thick);
     198                        }
     199
    173200                }
    174201
     
    198225
    199226                Item.DuplicateItem(this, copy);
    200 
    201                 copy.setThickness(getThickness());
    202                 copy.setPointType(_pointType);
    203                 copy.useFilledPoints(_filled);
    204227
    205228                return copy;
Note: See TracChangeset for help on using the changeset viewer.