blueprintstyle.java

来自「JAVA的一些源码 JAVA2 STANDARD EDITION DEVELO」· Java 代码 · 共 693 行 · 第 1/2 页

JAVA
693
字号
        }        public Color getOverlayColorizeColor() {            return overlayColorizeColor;        }        public int getArrowDirection() {            return arrowDirection;        }        public int getOrientation() {            return orientation;        }        private Image getImage(final Object o) {            if (o == null || o instanceof Image) {                return (Image)o;            }            ImageIcon ii = (ImageIcon)AccessController.doPrivileged(new PrivilegedAction() {                public Object run() {                    return new ImageIcon((String)o);                }            });            if (ii.getIconWidth() > 0 && ii.getIconHeight() > 0) {                return ii.getImage();            }                        return null;        }        /**         * Will return < 0 if doesn't match, otherwise return the         * number of parameters that match.         */        int getMatchCount(String detail, int componentState, int shadow,                          int orientation, int gapSide, int arrowDirection,                          String parentType) {            int matchCount = 0;            if (this.componentState != UNDEFINED) {                if (componentState != UNDEFINED &&                             this.componentState != componentState) {                    return -1;                }                matchCount++;            }            if (this.shadow != UNDEFINED) {                if (shadow != UNDEFINED && this.shadow != shadow) {                    return -1;                }                matchCount++;            }            if (this.arrowDirection != UNDEFINED) {                if (arrowDirection != UNDEFINED &&                        this.arrowDirection != arrowDirection) {                    return -1;                }                matchCount++;            }            if (this.orientation != UNDEFINED) {                if (orientation != UNDEFINED &&                                   this.orientation != orientation) {                    return -1;                }                matchCount++;            }            if (this.gapSide != UNDEFINED) {                if (gapSide != UNDEFINED && this.gapSide != gapSide) {                    return -1;                }                matchCount++;            }            if (this.detail != null) {                if (this.detail != detail) {                    return -1;                }                matchCount++;            }            if (this.parentTypeList != null) {                boolean found = false;                String type;                Iterator itr = parentTypeList.iterator();                while (itr.hasNext() && !found) {                    type = (String)itr.next();                    // NOTE: Maybe we should compare all lowercase.                    if (type == parentType) {                        found = true;                    }                }                if (!found) {                    return -1;                }                matchCount++;            }            return matchCount;        }        /**         * Returns true if this Info matches that of the passed in Info.         * This differs from equals in so far as this only compares the         * properties that are used in lookup vs the actual images or         * insets.         *         * @return true if the receiver and info can be considered equal         *         for lookup.         */        boolean matches(Info info) {            return (info.function == function && info.detail == detail &&                    info.componentState == componentState &&                    info.shadow == shadow && info.gapSide == gapSide &&                    info.arrowDirection == arrowDirection &&                    info.orientation == orientation);        }        public String toString() {            StringBuffer buf = new StringBuffer();            buf.append("IMAGE:\n");            if (function != null) {                buf.append("    function=").append(function).append('\n');            }            if (detail != null) {                buf.append("    detail=").append(detail).append('\n');            }            if (gapSide != UNDEFINED) {                buf.append("    gapSide=");                buf.append(getSideName(gapSide)).append('\n');            }            if (orientation != UNDEFINED) {                buf.append("    orientation=");                buf.append(getOrientName(orientation)).append('\n');            }            if (componentState != UNDEFINED) {                buf.append("    componentState=");                buf.append(getStateName(componentState, "UNDEFINED")).append('\n');            }            if (shadow != UNDEFINED) {                buf.append("    shadow=");                buf.append(getShadowName(shadow)).append('\n');            }            if (arrowDirection != UNDEFINED) {                buf.append("    arrowDirection=");                buf.append(getArrowDirectionName(arrowDirection)).append('\n');            }            if (parentTypeList != null) {                buf.append("    parent_type={");                for (Iterator iter = parentTypeList.iterator();                        iter.hasNext(); ) {                    buf.append(iter.next()).append(", ");                }                buf.deleteCharAt(buf.length() - 1).deleteCharAt(buf.length() - 1);                buf.append("}\n");            }            if (useAsBkgMask != false) {                buf.append("    use_as_bkg_mask=").append(useAsBkgMask).append('\n');            }            if (image != null) {                buf.append("    image=").append(image).append('\n');            }            if (fileInsets != null) {                buf.append("    fileInsets=").append(fileInsets).append('\n');            }            if (stretch != false) {                buf.append("    stretch=").append(stretch).append('\n');            }            if (recolorable != false) {                buf.append("    recolorable=").append(recolorable).append('\n');            }            if (colorizeColor != null) {                buf.append("    colorize_color=");                buf.append(getColorStringWithAlpha(colorizeColor)).append('\n');            }            if (overlayImage != null) {                buf.append("    overlayImage=").append(overlayImage).append('\n');            }            if (overlayInsets != null) {                buf.append("    overlayInsets=").append(overlayInsets).append('\n');            }            if (overlayStretch != false) {                buf.append("    overlayStretch=").append(overlayStretch).append('\n');            }            if (overlayRecolorable != false) {                buf.append("    overlay_recolorable=").append(overlayRecolorable).append('\n');            }            if (overlayColorizeColor != null) {                buf.append("    overlay_colorize_color=");                buf.append(getColorStringWithAlpha(overlayColorizeColor)).append('\n');            }            if (gapStartImage != null) {                buf.append("    gapStartImage=").append(gapStartImage).append('\n');            }            if (gapStartInsets != null) {                buf.append("    gapStartInsets=").append(gapStartInsets).append('\n');            }            if (gapImage != null) {                buf.append("    gapImage=").append(gapImage).append('\n');            }            if (gapInsets != null) {                buf.append("    gapInsets=").append(gapInsets).append('\n');            }            if (gapEndImage != null) {                buf.append("    gapEndImage=").append(gapEndImage).append('\n');            }            if (gapEndInsets != null) {                buf.append("    gapEndInsets=").append(gapEndInsets).append('\n');            }            buf.deleteCharAt(buf.length() - 1);            return buf.toString();        }                private static String getSideName(int side) {            switch(side) {                case TOP: return "TOP";                case BOTTOM: return "BOTTOM";                case LEFT: return "LEFT";                case RIGHT: return "RIGHT";                case UNDEFINED: return "UNDEFINED";            }                        return "UNKNOWN";        }                private static String getOrientName(int orient) {            switch(orient) {                case HORIZONTAL: return "HORIZONTAL";                case VERTICAL: return "VERTICAL";                case UNDEFINED: return "UNDEFINED";            }                        return "UNKNOWN";        }                private static String getShadowName(int shadow) {            switch(shadow) {                case SHADOW_IN: return "SHADOW_IN";                case SHADOW_OUT: return "SHADOW_OUT";                case SHADOW_ETCHED_IN: return "SHADOW_ETCHED_IN";                case SHADOW_ETCHED_OUT: return "SHADOW_ETCHED_OUT";                case SHADOW_NONE: return "SHADOW_NONE";                case UNDEFINED: return "UNDEFINED";            }                        return "UNKNOWN";        }        private static String getArrowDirectionName(int dir) {            switch(dir) {                case ARROW_UP: return "ARROW_UP";                case ARROW_DOWN: return "ARROW_DOWN";                case ARROW_LEFT: return "ARROW_LEFT";                case ARROW_RIGHT: return "ARROW_RIGHT";                case UNDEFINED: return "UNDEFINED";            }            return "UNKNOWN";        }    }    private static String getColorStringWithAlpha(Color c) {        if (c == null) {            return "null";        }        StringBuffer buf = new StringBuffer();        buf.append('{');        buf.append(c.getRed()).append(", ");        buf.append(c.getGreen()).append(", ");        buf.append(c.getBlue()).append(", ");        buf.append(c.getAlpha()).append("}");        return buf.toString();    }    public String toString() {        StringBuffer buf = new StringBuffer(super.toString());        if (buf.length() > 0) {            buf.append('\n');        }        buf.append("*** Blueprint Engine Info ***\n");        buf.append("icon_colorize = " + iconColorize + '\n');        buf.append("icon_colorize_ancestor_type = ");        if (iconAncestorTypes == null) {            buf.append("null\n");        } else {            buf.append('{');            for (int i = 0; i < iconAncestorTypes.length; i++) {                buf.append(iconAncestorTypes[i] + ", ");            }            buf.deleteCharAt(buf.length() - 1);            buf.deleteCharAt(buf.length() - 1);            buf.append("}\n");        }        buf.append("colorize_color = ");        buf.append(getColorStringWithAlpha(colorizeColor));        buf.append('\n');        if (info != null) {            for (int i = 0; i < info.length; i++) {                buf.append(info[i].toString()).append('\n');            }        }        // remove last newline        buf.deleteCharAt(buf.length() - 1);        return buf.toString();    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?