Ignore:
Timestamp:
07/16/08 18:10:56 (16 years ago)
Author:
ra33
Message:
 
File:
1 edited

Legend:

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

    r143 r145  
    55import java.awt.Cursor;
    66import java.awt.Dimension;
     7import java.awt.GradientPaint;
    78import java.awt.Graphics2D;
    89import java.awt.Point;
     
    157158                dest.setTag(source.getTag());
    158159                dest.setFillColor(source.getFillColor());
     160                dest.setGradientColor(source.getGradientColor());
    159161                dest.setFillPattern(source.getFillPattern());
    160162
     
    254256        // A fill color of null represents transparent
    255257        private Color _colorFill = null;
     258
     259        // A gradient color of null represents NO gradient
     260        private Color _colorGradient = null;
    256261
    257262        // A fore color of null represents the default color
     
    946951                        if (isFloating()) {
    947952                                // TODO experiment with adding alpha when picking up filled
    948                                 // items...
    949                                 // Slows things down quite alot!!
     953                                // items... Slows things down quite alot!!
    950954                                fillColor = new Color(fillColor.getRed(), fillColor.getGreen(),
    951955                                                fillColor.getBlue());
    952956                        }
    953957                        g.setColor(fillColor);
    954                         // The painting is not efficient enough for gradients...
    955                         // Polygon s = getEnclosedShape();
    956                         // Rectangle b = s.getBounds();
    957                         // GradientPaint gp = new GradientPaint((int) (b.x + b.width * 0.3),
    958                         // b.y, getFillColor(), (int) (b.x + b.width * 1.3), b.y,
    959                         // Color.white);
    960                         // g.setPaint(gp);
    961                         // g.fillPolygon(s);
    962                         g.fillPolygon(getEnclosedShape());
     958                        Color gradientColor = getGradientColor();
     959                        if (gradientColor != null) {
     960                                // The painting is not efficient enough for gradients...
     961                                Polygon s = getEnclosedShape();
     962                                Rectangle b = s.getBounds();
     963                                GradientPaint gp = new GradientPaint(
     964                                                (int) (b.x + b.width * 0.3), b.y, fillColor,
     965                                                (int) (b.x + b.width * 1.3), b.y, gradientColor);
     966                                g.setPaint(gp);
     967                                g.fillPolygon(s);
     968                        } else {
     969                                g.fillPolygon(getEnclosedShape());
     970                        }
    963971                }
    964972        }
     
    12341242                invalidateCommonTrait(ItemAppearence.FillColor);
    12351243                invalidateFill();
     1244        }
     1245
     1246        public void setGradientColor(Color c) {
     1247                _colorGradient = c;
     1248
     1249                for (Line line : _lines) {
     1250                        Item other = line.getOppositeEnd(this);
     1251                        if (other.getGradientColor() != c)
     1252                                other.setGradientColor(c);
     1253                }
     1254
     1255                invalidateCommonTrait(ItemAppearence.GradientColor);
     1256                invalidateFill();
     1257        }
     1258
     1259        public Color getGradientColor() {
     1260                return _colorGradient;
    12361261        }
    12371262
     
    23192344                // will ID still
    23202345                // be -1 when saving a frame?
    2321                 //assert (i != null);
     2346                // assert (i != null);
    23222347                return !isVisible() || getID() < 0 || offScreenTopOrLeft();
    23232348        }
Note: See TracChangeset for help on using the changeset viewer.