@Override protected void populateMockData() { // mock up some data getMockObject().setSource(source); name("Connector " + seed) .id(CatalogItemMockFactory.class.getPackage().getName() + ".connector" + seed) .siteUrl("http://example.nodomain/some/path/updateSite3.x/") .tag(new Tag("", "")) .license(seed % 2 == 0 ? "EPL 1.0" : "APL 2.0") .description("a connector for the Example Task System versions 1.0 - 5.3") .categoryId("example") .provider( "Testing 123 Inc."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ // //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ // //$NON-NLS-9$ //$NON-NLS-10$ Icon icon = new Icon(); icon.setImage128("images/ico128.png"); // $NON-NLS-1$ icon.setImage16("images/ico16.png"); // $NON-NLS-1$ icon.setImage32("images/ico32.png"); // $NON-NLS-1$ icon.setImage64("images/ico64.png"); // $NON-NLS-1$ Overview overview = new Overview(); overview.setScreenshot("images/screenshot-main.png"); // $NON-NLS-1$ overview.setSummary("some long text that summarizes the connector"); // $NON-NLS-1$ overview.setUrl("http://example.nodomain/some/path/updateSite3.x/overview.html"); // $NON-NLS-1$ icon(icon).overview(overview); overview.setItem(getMockObject()); }
public void paintThumb(Graphics g) { Icon icon = null; if (slider.getOrientation() == JSlider.HORIZONTAL) { if (isRollover && slider.isEnabled()) { icon = getThumbHorIconRollover(); } else { icon = getThumbHorIcon(); } } else { if (isRollover && slider.isEnabled()) { icon = getThumbVerIconRollover(); } else { icon = getThumbVerIcon(); } } Graphics2D g2D = (Graphics2D) g; Composite savedComposite = g2D.getComposite(); if (!slider.isEnabled()) { g.setColor(AbstractLookAndFeel.getBackgroundColor()); g.fillRect(thumbRect.x + 1, thumbRect.y + 1, thumbRect.width - 2, thumbRect.height - 2); AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f); g2D.setComposite(alpha); } icon.paintIcon(null, g, thumbRect.x, thumbRect.y); g2D.setComposite(savedComposite); }
public void paintIcon(Component c, Graphics g, int x, int y) { boolean enabled = c.isEnabled(); // paint the icon Icon paintedIcon = enabled ? icon : disabledIcon; if (paintedIcon != null) paintedIcon.paintIcon(c, g, x, y); // backup current color Color oldColor = g.getColor(); int insetx = 4; if (c instanceof JComponent) { Insets borderinset = ((JComponent) c).getBorder().getBorderInsets(c); insetx = borderinset.left; } if (paintedIcon != null) { g.translate(paintedIcon.getIconWidth() + X_GAP + insetx, 0); } arrow.paintIcon(c, g, x, y); if (paintedIcon != null) { g.translate(-paintedIcon.getIconWidth() - X_GAP - insetx, 0); } // restore previous color g.setColor(oldColor); }
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) { AbstractButton b = (AbstractButton) c; ButtonModel model = b.getModel(); Icon icon = b.getIcon(); Icon tmpIcon = null; if (icon == null) { return; } Icon selectedIcon = null; /* the fallback icon should be based on the selected state */ if (model.isSelected()) { selectedIcon = (Icon) b.getSelectedIcon(); if (selectedIcon != null) { icon = selectedIcon; } } if (!model.isEnabled()) { if (model.isSelected()) { tmpIcon = (Icon) b.getDisabledSelectedIcon(); if (tmpIcon == null) { tmpIcon = selectedIcon; } } if (tmpIcon == null) { tmpIcon = (Icon) b.getDisabledIcon(); } } else if (model.isPressed() && model.isArmed()) { tmpIcon = (Icon) b.getPressedIcon(); if (tmpIcon != null) { // revert back to 0 offset clearTextShiftOffset(); } } else if (b.isRolloverEnabled() && model.isRollover()) { if (model.isSelected()) { tmpIcon = (Icon) b.getRolloverSelectedIcon(); if (tmpIcon == null) { tmpIcon = selectedIcon; } } if (tmpIcon == null) { tmpIcon = (Icon) b.getRolloverIcon(); } } if (tmpIcon != null) { icon = tmpIcon; } if (model.isPressed() && model.isArmed()) { icon.paintIcon(c, g, iconRect.x + getTextShiftOffset(), iconRect.y + getTextShiftOffset()); } else { icon.paintIcon(c, g, iconRect.x, iconRect.y); } }
public void paint(Graphics g) { Dimension size = getSize(); Color colors[]; if (isEnabled()) { if (getModel().isArmed() && getModel().isPressed()) { colors = BaseLookAndFeel.getTheme().getPressedColors(); } else if (getModel().isRollover()) { colors = BaseLookAndFeel.getTheme().getRolloverColors(); } else { colors = BaseLookAndFeel.getTheme().getButtonColors(); } } else { colors = BaseLookAndFeel.getTheme().getDisabledColors(); } Utilities.fillHorGradient(g, colors, 0, 0, size.width, size.height); boolean inverse = ColorHelper.getGrayValue(colors) < 128; Icon icon = inverse ? BaseIcons.getComboBoxInverseIcon() : BaseIcons.getComboBoxIcon(); int x = (size.width - icon.getIconWidth()) / 2; int y = (size.height - icon.getIconHeight()) / 2; Graphics2D g2D = (Graphics2D) g; Composite savedComposite = g2D.getComposite(); g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f)); if (getModel().isPressed() && getModel().isArmed()) { icon.paintIcon(this, g, x + 2, y + 1); } else { icon.paintIcon(this, g, x + 1, y); } g2D.setComposite(savedComposite); paintBorder(g2D); }
private Icon getIcon(DaemonCodeAnalyzerStatus status) { if (status == null) { return NO_ICON; } if (status.noHighlightingRoots != null && status.noHighlightingRoots.length == status.rootsNumber) { return NO_ANALYSIS_ICON; } Icon icon = HighlightDisplayLevel.DO_NOT_SHOW.getIcon(); for (int i = status.errorCount.length - 1; i >= 0; i--) { if (status.errorCount[i] != 0) { icon = mySeverityRegistrar.getRendererIconByIndex(i); break; } } if (status.errorAnalyzingFinished) { if (myProject != null && DumbService.isDumb(myProject)) { return new LayeredIcon(NO_ANALYSIS_ICON, icon, STARING_EYE_ICON); } return icon; } if (!status.enabled) return NO_ANALYSIS_ICON; double progress = getOverallProgress(status); TruncatingIcon trunc = new TruncatingIcon(icon, icon.getIconWidth(), (int) (icon.getIconHeight() * progress)); return new LayeredIcon(NO_ANALYSIS_ICON, trunc, STARING_EYE_ICON); }
private void render() { if (iconPosition == IconPosition.LEFT) { getElement().insertAfter(icon.getElement(), inputElem); } else { getElement().insertAfter(icon.getElement(), null); } }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { final Icon icon = getOrComputeIcon(); if (icon != null) { icon.paintIcon(c, g, x, y); } }
@Override protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) { AbstractButton b = (AbstractButton) c; ButtonModel model = b.getModel(); Icon icon = b.getIcon(); Icon tmpIcon = null; Icon shadowIcon = null; boolean borderHasPressedCue = borderHasPressedCue(b); if (icon == null) { return; } if (!model.isEnabled()) { if (model.isSelected()) { tmpIcon = (Icon) b.getDisabledSelectedIcon(); } else { tmpIcon = (Icon) b.getDisabledIcon(); } } else if (model.isPressed() && model.isArmed()) { tmpIcon = (Icon) b.getPressedIcon(); if (tmpIcon != null) { // revert back to 0 offset clearTextShiftOffset(); } else if (icon != null && icon instanceof ImageIcon && !borderHasPressedCue) { // Create an icon on the fly. // Note: This is only needed for borderless buttons, which // have no other way to provide feedback about the pressed // state. tmpIcon = new ImageIcon(HalfbrightFilter.createHalfbrightImage(((ImageIcon) icon).getImage())); shadowIcon = new ImageIcon(ShadowFilter.createShadowImage(((ImageIcon) icon).getImage())); } } else if (b.isRolloverEnabled() && model.isRollover()) { if (model.isSelected()) { tmpIcon = b.getRolloverSelectedIcon(); if (tmpIcon == null) { tmpIcon = b.getSelectedIcon(); } } else { tmpIcon = (Icon) b.getRolloverIcon(); } } else if (model.isSelected()) { tmpIcon = b.getSelectedIcon(); } if (tmpIcon != null) { icon = tmpIcon; } if (model.isPressed() && model.isArmed()) { if (shadowIcon != null) { shadowIcon.paintIcon( c, g, iconRect.x + getTextShiftOffset(), iconRect.y + getTextShiftOffset() + 1); } icon.paintIcon(c, g, iconRect.x + getTextShiftOffset(), iconRect.y + getTextShiftOffset()); } else { icon.paintIcon(c, g, iconRect.x, iconRect.y); } }
@Override public void paint(Component c, Graphics g, Rectangle r) { DaemonCodeAnalyzerStatus status = getDaemonCodeAnalyzerStatus(false, mySeverityRegistrar); Icon icon = getIcon(status); int height = icon.getIconHeight(); int width = icon.getIconWidth(); int x = r.x + (r.width - width) / 2; int y = r.y + (r.height - height) / 2; icon.paintIcon(c, g, x, y); /* if (status != null && status.enabled && !status.errorAnalyzingFinished) { Color oldColor = g.getColor(); g.setColor(Color.gray); //UIUtil.drawDottedRectangle(g, x, y, x + width, y + height); Graphics2D g2 = (Graphics2D)g; final Stroke saved = g2.getStroke(); g2.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, new float[]{3,1,1,1}, System.currentTimeMillis() % 400 / 100)); g2.drawRect(x-1, y-1, width, height); //g2.drawRect(r.x, r.y, r.width, r.height); g2.setStroke(saved); g.setColor(oldColor); } */ }
private void calcMaxIconSize(final ActionGroup actionGroup) { AnAction[] actions = actionGroup.getChildren(createActionEvent(actionGroup)); for (AnAction action : actions) { if (action == null) continue; if (action instanceof ActionGroup) { final ActionGroup group = (ActionGroup) action; if (!group.isPopup()) { calcMaxIconSize(group); continue; } } Icon icon = action.getTemplatePresentation().getIcon(); if (icon == null && action instanceof Toggleable) icon = PlatformIcons.CHECK_ICON; if (icon != null) { final int width = icon.getIconWidth(); final int height = icon.getIconHeight(); if (myMaxIconWidth < width) { myMaxIconWidth = width; } if (myMaxIconHeight < height) { myMaxIconHeight = height; } } } }
/** * Gets (creates if necessary) disabled icon based on the passed one. * * @return <code>ImageIcon</code> constructed from disabled image of passed icon. */ @Nullable public static Icon getDisabledIcon(Icon icon) { if (icon instanceof LazyIcon) icon = ((LazyIcon) icon).getOrComputeIcon(); if (icon == null) return null; Icon disabledIcon = ourIcon2DisabledIcon.get(icon); if (disabledIcon == null) { if (!isGoodSize(icon)) { LOG.error(icon); // # 22481 return EMPTY_ICON; } final int scale = UIUtil.isRetina() ? 2 : 1; @SuppressWarnings("UndesirableClassUsage") BufferedImage image = new BufferedImage( scale * icon.getIconWidth(), scale * icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); final Graphics2D graphics = image.createGraphics(); graphics.setColor(UIUtil.TRANSPARENT_COLOR); graphics.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight()); graphics.scale(scale, scale); icon.paintIcon(LabelHolder.ourFakeComponent, graphics, 0, 0); graphics.dispose(); Image img = ImageUtil.filter(image, UIUtil.getGrayFilter()); if (UIUtil.isRetina()) img = RetinaImage.createFrom(img, 2, ImageLoader.ourComponent); disabledIcon = new JBImageIcon(img); ourIcon2DisabledIcon.put(icon, disabledIcon); } return disabledIcon; }
@Override protected void doWidgetLayout(LayoutHelper helper) { int availableWidth = helper.getParentWidth() - (buttons.size() - 1) * 2; // account for gaps int buttonWidth = availableWidth / buttons.size(); Graphics g = buttons.get(0).getGraphics(); if (buttonWidth <= 0 || g == null) { return; } int maxTextWidth = buttonWidth - 8; // account for padding for (FLabel btn : buttons) { if (btn.getText() != null && !btn.getText().isEmpty()) { int max = maxTextWidth; Icon icon = btn.getIcon(); if (icon != null) { max -= icon.getIconWidth() + 4; } for (int fs = 11; fs > 5; fs--) { SkinFont skinFont = FSkin.getFont(fs); if (skinFont.measureTextWidth(g, btn.getText()) <= max) { btn.setFont(skinFont); break; } } } helper.include(btn, buttonWidth, 25); helper.offset(-1, 0); // keep buttons tighter together } }
private static BufferedImage makeBufferedImage(Icon icon, int w, int h) { BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); icon.paintIcon(null, g, (w - icon.getIconWidth()) / 2, (h - icon.getIconWidth()) / 2); g.dispose(); return image; }
@NotNull public static Icon colorize(@NotNull final Icon source, @NotNull Color color, boolean keepGray) { float[] base = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); final BufferedImage image = UIUtil.createImage(source.getIconWidth(), source.getIconHeight(), Transparency.TRANSLUCENT); final Graphics2D g = image.createGraphics(); source.paintIcon(null, g, 0, 0); g.dispose(); final BufferedImage img = UIUtil.createImage(source.getIconWidth(), source.getIconHeight(), Transparency.TRANSLUCENT); int[] rgba = new int[4]; float[] hsb = new float[3]; for (int y = 0; y < image.getRaster().getHeight(); y++) { for (int x = 0; x < image.getRaster().getWidth(); x++) { image.getRaster().getPixel(x, y, rgba); if (rgba[3] != 0) { Color.RGBtoHSB(rgba[0], rgba[1], rgba[2], hsb); int rgb = Color.HSBtoRGB(base[0], base[1] * (keepGray ? hsb[1] : 1f), base[2] * hsb[2]); img.getRaster() .setPixel(x, y, new int[] {rgb >> 16 & 0xff, rgb >> 8 & 0xff, rgb & 0xff, rgba[3]}); } } } return createImageIcon(img); }
private Icon getAllowedIcon() { Icon icon = menuItem.isEnabled() ? menuItem.getIcon() : menuItem.getDisabledIcon(); if (icon != null && icon.getIconWidth() > myMaxGutterIconWidth) { icon = null; } return icon; }
@NotNull private static Icon createEmptyIconLike(@NotNull String baseIconPath) { Icon baseIcon = IconLoader.findIcon(baseIconPath); if (baseIcon == null) { return EmptyIcon.ICON_16; } return new EmptyIcon(baseIcon.getIconWidth(), baseIcon.getIconHeight()); }
private void ammoChange(AmmoData ad) { ammoICO.setImage(ad.image); GreenfootImage i = ammoICO.getImage(); i.scale((int) (ad.width * 1.75), (int) (ad.height * 1.75)); playerAmmo = ad; ammoUI.setPoints(ammo[playerAmmunition.indexOf(ad)]); }
public int getIconHeight(SynthContext context) { Icon icon = getIcon(context); if (icon != null) { return icon.getIconHeight(); } return 0; }
/** * Does all the initial setup of the button such as retrieving all the attributes that were set in * xml and inflating the like button's view and initial state. * * @param context * @param attrs * @param defStyle */ private void init(Context context, AttributeSet attrs, int defStyle) { LayoutInflater.from(getContext()).inflate(R.layout.likeview, this, true); icon = (ImageView) findViewById(R.id.icon); dotsView = (DotsView) findViewById(R.id.dots); circleView = (CircleView) findViewById(R.id.circle); final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.LikeButton, defStyle, 0); iconSize = array.getDimensionPixelSize(R.styleable.LikeButton_icon_size, -1); if (iconSize == -1) iconSize = 40; String iconType = array.getString(R.styleable.LikeButton_icon_type); likeDrawable = array.getDrawable(R.styleable.LikeButton_like_drawable); if (likeDrawable != null) setLikeDrawable(likeDrawable); unLikeDrawable = array.getDrawable(R.styleable.LikeButton_unlike_drawable); if (unLikeDrawable != null) setUnlikeDrawable(unLikeDrawable); if (iconType != null) if (!iconType.isEmpty()) currentIcon = parseIconType(iconType); circleStartColor = array.getColor(R.styleable.LikeButton_circle_start_color, 0); if (circleStartColor != 0) circleView.setStartColor(circleStartColor); circleEndColor = array.getColor(R.styleable.LikeButton_circle_end_color, 0); if (circleEndColor != 0) circleView.setEndColor(circleEndColor); dotPrimaryColor = array.getColor(R.styleable.LikeButton_dots_primary_color, 0); dotSecondaryColor = array.getColor(R.styleable.LikeButton_dots_secondary_color, 0); if (dotPrimaryColor != 0 && dotSecondaryColor != 0) { dotsView.setColors(dotPrimaryColor, dotSecondaryColor); } if (likeDrawable == null && unLikeDrawable == null) { if (currentIcon != null) { setLikeDrawableRes(currentIcon.getOnIconResourceId()); setUnlikeDrawableRes(currentIcon.getOffIconResourceId()); } else { currentIcon = parseIconType(IconType.Heart); setLikeDrawableRes(currentIcon.getOnIconResourceId()); setUnlikeDrawableRes(currentIcon.getOffIconResourceId()); } } setEnabled(array.getBoolean(R.styleable.LikeButton_enabled, true)); Boolean status = array.getBoolean(R.styleable.LikeButton_liked, false); setAnimationScaleFactor(array.getFloat(R.styleable.LikeButton_anim_scale_factor, 3)); setLiked(status); setOnClickListener(this); array.recycle(); }
protected void paintComponent(Graphics g) { final Border border = getBorder(); int shiftX = 0; int shiftY = 0; if (border != null) { shiftX = border.getBorderInsets(this).left; shiftY = border.getBorderInsets(this).top; } setForeground(getTextColor()); super.paintComponent(g); if (getText() != null) { g.setColor(getTextColor()); int x = myIconWidth; int y = getTextBaseLine(); if (myUnderline) { int k = 1; if (getFont().getSize() > 11) { k += (getFont().getSize() - 11); } y += k; int lineY = y + shiftY; if (lineY >= getSize().height) { lineY = getSize().height - 1; } if (getHorizontalAlignment() == LEFT) { UIUtil.drawLine( g, x + shiftX, lineY, x + getFontMetrics(getFont()).stringWidth(getText()) + shiftX, lineY); } else { UIUtil.drawLine( g, getWidth() - 1 - getFontMetrics(getFont()).stringWidth(getText()) + shiftX, lineY, getWidth() - 1 + shiftX, lineY); } } else { } if (myPaintDefaultIcon) { int endX = myIconWidth + getFontMetrics(getFont()).stringWidth(getText()); int endY = getHeight() / 2 - LINK.getIconHeight() / 2 + 1; LINK.paintIcon(this, g, endX + shiftX + DEFAULT_ICON_GAP, endY); } } }
/** {@inheritDoc} */ public String getName(final String iconID) { final Icon icon = icons.get(iconID); if (icon != null) { return icon.getName(); } return null; }
/** {@inheritDoc} */ public IconState getState(final String iconID) { final Icon icon = icons.get(iconID); if (icon != null) { return icon.getState(); } return null; }
@Override public Collection<String> getIcons() { Collection<String> icons = new LinkedList<String>(); for (Icon value : Icon.values()) { icons.add(value.name()); } return icons; }
@Override public void paint(Graphics g, JComponent c) { JButton button = (JButton) c; String text = button.getText(); Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon(); if ((icon == null) && (text == null)) { return; } FontMetrics fm = g.getFontMetrics(); paintViewInsets = c.getInsets(paintViewInsets); paintViewR.x = paintViewInsets.left; paintViewR.y = paintViewInsets.top; // Use inverted height & width paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right); paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom); paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0; paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0; Graphics2D g2 = (Graphics2D) g; AffineTransform tr = g2.getTransform(); if (angle == 90) { g2.rotate(Math.PI / 2); g2.translate(0, -c.getWidth()); paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2; paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2; } else if (angle == 270) { g2.rotate(-Math.PI / 2); g2.translate(-c.getHeight(), 0); paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2; paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2; } if (icon != null) { icon.paintIcon(c, g, paintIconR.x, paintIconR.y); } if (text != null) { int textX = paintTextR.x; int textY = paintTextR.y + fm.getAscent(); if (button.isEnabled()) { paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text); } else { paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text); } } g2.setTransform(tr); }
public void paintIcon(SynthContext context, Graphics g, int x, int y, int w, int h) { Icon icon = getIcon(context); if (icon != null) { if (context == null) { icon.paintIcon(null, g, x, y); } else { icon.paintIcon(context.getComponent(), g, x, y); } } }
/** * Parses the specific icon based on it's type. These icons are bundled with the library and are * accessed via objects that contain their resource ids and an enum with their name. * * @param iconType * @return */ private Icon parseIconType(IconType iconType) { List<Icon> icons = Utils.getIcons(); for (Icon icon : icons) { if (icon.getIconType().equals(iconType)) { return icon; } } throw new IllegalArgumentException("Correct icon type not specified."); }
@NotNull private static Icon getEmptyPinIcon() { if (ourEmptyPinIcon == null) { Icon icon = AllIcons.Nodes.PinToolWindow; int width = icon.getIconWidth(); ourEmptyPinIcon = IconUtil.cropIcon( icon, new Rectangle(width / 2, 0, width - width / 2, icon.getIconHeight())); } return ourEmptyPinIcon; }
public static void removeIcon(Player player, Location l) { if (l == null) { return; } int slot = freeIconSlot(player, l); Icon icon = player.getAttribute("icon_slot" + slot); if (icon != null) { icon.targetType = 0; ActionSender.sendHintIcon(player, icon); player.removeAttribute("icon_slot" + slot); } }
@Override public HashMap<String, Character> getCharacters() { if (mChars == null) { HashMap<String, Character> aChars = new HashMap<String, Character>(); for (Icon v : Icon.values()) { aChars.put(v.name(), v.character); } mChars = aChars; } return mChars; }