Ignore:
Timestamp:
07/18/08 14:28:41 (16 years ago)
Author:
ra33
Message:

Added anchorRight and anchorBottom properties to items...
Fixed bugs with @i item display...
Can now inject properties into enclosed items at the same time

File:
1 edited

Legend:

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

    r145 r147  
    44import java.awt.Color;
    55import java.awt.Cursor;
    6 import java.awt.Dimension;
    76import java.awt.GradientPaint;
    87import java.awt.Graphics2D;
     
    109import java.awt.Polygon;
    1110import java.awt.Rectangle;
     11import java.awt.Shape;
    1212import java.awt.Stroke;
    1313import java.awt.geom.AffineTransform;
     
    167167                dest.setLinkTemplate(source.getLinkTemplate());
    168168
    169                 dest.setMaxSize(source.getMaxSize());
     169                // dest.setMaxWidth(source.getMaxWidth());
     170
    170171                dest.setOffset(source.getOffset());
    171172                dest.setOwner(source.getOwner());
     
    210211        }
    211212
     213        private Float _anchorRight = null;
     214
     215        private Float _anchorBottom = null;
     216
    212217        protected HighlightMode _mode = HighlightMode.None;
    213218
     
    228233        private boolean _highlight = true;
    229234
    230         private Dimension _maxSize = null;
     235        // private int _maxWidth = -1;
    231236
    232237        private String _owner = null;
     
    719724        }
    720725
    721         public Dimension getMaxSize() {
    722                 return _maxSize;
    723         }
     726        // public int getMaxWidth() {
     727        // return _maxWidth;
     728        // }
    724729
    725730        public Point getOffset() {
     
    949954                Color fillColor = getFillColor();
    950955                if (fillColor != null && getEnclosingDots() != null) {
    951                         if (isFloating()) {
    952                                 // TODO experiment with adding alpha when picking up filled
    953                                 // items... Slows things down quite alot!!
    954                                 fillColor = new Color(fillColor.getRed(), fillColor.getGreen(),
    955                                                 fillColor.getBlue());
    956                         }
    957                         g.setColor(fillColor);
    958                         Color gradientColor = getGradientColor();
    959                         if (gradientColor != null) {
    960                                 // The painting is not efficient enough for gradients...
    961                                 Polygon s = getEnclosedShape();
     956                        setFillPaint(g);
     957                        g.fillPolygon(getEnclosedShape());
     958                }
     959        }
     960
     961        protected void setFillPaint(Graphics2D g) {
     962                Color fillColor = getFillColor();
     963                if (isFloating()) {
     964                        // TODO experiment with adding alpha when picking up filled
     965                        // items... Slows things down quite alot!!
     966                        fillColor = new Color(fillColor.getRed(), fillColor.getGreen(),
     967                                        fillColor.getBlue());
     968                }
     969                g.setColor(fillColor);
     970                Color gradientColor = getGradientColor();
     971                if (gradientColor != null) {
     972                        // The painting is not efficient enough for gradients...
     973                        Shape s = getEnclosedShape();
     974                        if (s != null) {
    962975                                Rectangle b = s.getBounds();
    963976                                GradientPaint gp = new GradientPaint(
     
    965978                                                (int) (b.x + b.width * 1.3), b.y, gradientColor);
    966979                                g.setPaint(gp);
    967                                 g.fillPolygon(s);
    968                         } else {
    969                                 g.fillPolygon(getEnclosedShape());
    970980                        }
    971981                }
     
    13641374        }
    13651375
    1366         /**
    1367         * Sets the maximum coordinates on the screen that this item may occupy.
    1368         * This is used by Text items to compute word-wrapping lengths.
    1369          *
    1370         * @param d
    1371          *            The Maximum size of the Frame containing this Item.
    1372         */
    1373         public void setMaxSize(Dimension d) {
    1374                 if (d != null) {
    1375                         _maxSize = d;
    1376                         updatePolygon();
    1377                 }
    1378         }
     1376        // /**
     1377        // * Sets the maximum coordinates on the screen that this item may occupy.
     1378        // * This is used by Text items to compute word-wrapping lengths.
     1379        // *
     1380        // * @param d
     1381        // * The Maximum size of the Frame containing this Item.
     1382        // */
     1383        // public void setMaxWidth(int width) {
     1384        // if (width > 0) {
     1385        // _maxWidth = width;
     1386        // updatePolygon();
     1387        // }
     1388        // }
    13791389
    13801390        public void setOffset(int x, int y) {
     
    23472357                return !isVisible() || getID() < 0 || offScreenTopOrLeft();
    23482358        }
     2359
     2360        public void setAnchorRight(Float anchor) {
     2361                this._anchorRight = anchor;
     2362                if (anchor != null)
     2363                        setX(FrameGraphics.getMaxFrameSize().width - anchor);
     2364        }
     2365
     2366        public Float getAnchorRight() {
     2367                return _anchorRight;
     2368        }
     2369
     2370        public void setAnchorBottom(Float anchor) {
     2371                this._anchorBottom = anchor;
     2372                if (anchor != null)
     2373                        setY(FrameGraphics.getMaxFrameSize().height - anchor);
     2374        }
     2375
     2376        public Float getAnchorBottom() {
     2377                return _anchorBottom;
     2378        }
    23492379}
Note: See TracChangeset for help on using the changeset viewer.