public ZoomedIcon(final UIIcon uiIcon, final float zoom) { super(uiIcon.getName(), uiIcon.getFileName(), uiIcon.getDescriptionTranslationKey(), uiIcon.getShortcutKey()); this.uiIcon = uiIcon; this.zoom = zoom; }
@Override public boolean equals(final Object obj) { return super.equals(obj) && zoom == ((ZoomedIcon) obj).zoom; }
public void addIcon(final UIIcon uiIcon) { mIcons.add(uiIcon.getIcon()); mUIIcons.add(uiIcon); }
/** * @param map */ static void copyIconsToDirectory(final MapModel map, final String directoryName) { final ListModel icons = map.getIconRegistry().getIconsAsListModel(); for (int i = 0; i < icons.getSize(); i++) { final UIIcon icon = (UIIcon) icons.getElementAt(i); final String iconName = icon.getName(); final StringBuilder sb = new StringBuilder(directoryName); final int lastIndexOfSeparator = iconName.lastIndexOf('/'); if (lastIndexOfSeparator != -1) { sb.append(File.separatorChar); sb.append(iconName.substring(0, lastIndexOfSeparator)); } final File destinationDirectory = new File(sb.toString()); destinationDirectory.mkdirs(); FileUtils.copyFromURL(icon.getUrl(), destinationDirectory); } }
private static boolean isStateIconContained(final NodeModel node, final String iconName) { final Collection<UIIcon> stateIcons = IconController.getController().getStateIcons(node); for (final UIIcon stateIcon : stateIcons) { if (iconName.equals(stateIcon.getName())) { return true; } } return false; }
@Override public URL getUrl() { return uiIcon.getUrl(); }
@Override public String getPath() { return uiIcon.getPath(); }
public void addUIIcon(final UIIcon uiIcon) { uiIcons.put(uiIcon.getFileName(), uiIcon); }
public String getPath() { StringBuilder builder = new StringBuilder(); builder = new StringBuilder(); builder.append(this.getImagePath()); builder.append(SEPARATOR); builder.append(fileName); final String path = parentDirPattern.matcher(builder.toString()).replaceFirst(SEPARATOR); return path; }
/** * Returns a UIIcon with a given name. If one is not found in the store, * it will be created and stored. * * @param name of UIIcon to return * @return UIIcon with given name */ public UIIcon getUIIcon(final String name) { UIIcon result; if (mindIcons.containsKey(name)) { result = mindIcons.get(name); } else if (uiIcons.containsKey(name)) { result = uiIcons.get(name); } else { result = new UIIcon(name, name); uiIcons.put(name, result); } return result; } }
public boolean onIconClicked(IconClickedEvent event) { final boolean canProcess = event.getUIIcon().getName().equals(OpenMapsNodeHook.ICON_NAME); if (canProcess) nodeHook.viewCurrentlySelectedLocation(event.getNode()); return canProcess; } });
public Icon getIcon(final UIIcon uiIcon) { return getIcon(uiIcon.getUrl(), DEFAULT_UI_ICON_HEIGHT); }
public ASelectableCondition createCondition(final Object selectedItem, final TranslatedObject simpleCond, final Object value, final boolean matchCase, final boolean approximateMatching) { if (simpleCond.objectEquals(ConditionFactory.FILTER_CONTAINS)) return value instanceof UIIcon ? new IconContainedCondition(((UIIcon) value).getName()) : null; if (simpleCond.objectEquals(ConditionFactory.FILTER_EXIST)) return new IconExistsCondition(); return null; }
public void addIcon(final UIIcon uiIcon, final NodeModel node) { mIcons.add(uiIcon.getIcon(node)); mUIIcons.add(uiIcon); }
public Icon getIcon(UIIcon uiIcon, Quantity<LengthUnits> iconHeight) { return getIcon(uiIcon.getUrl(), iconHeight); }
public URL getUrl() { if (resourceURL != null) { return resourceURL; } final String path = getPath(); resourceURL = RESOURCE_CONTROLLER.getIconResource(path); return resourceURL; }
private Icon getZoomedBitmapIcon() { if (zoomedIcon == null) { Map<Float, ImageIcon> icons = zoomedBitmapIcons.get(uiIcon); if (icons == null) { icons = new HashMap<Float, ImageIcon>(); zoomedBitmapIcons.put(uiIcon, icons); } zoomedIcon = icons.get(zoom); if (zoomedIcon != null) { return zoomedIcon; } final Icon icon = uiIcon.getIcon(); final int width = icon.getIconWidth(); final int height = icon.getIconHeight(); final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); final Graphics2D g = image.createGraphics(); icon.paintIcon(null, g, 0, 0); final Image scaledImage = image.getScaledInstance((int) (width * zoom), (int) (height * zoom), Image.SCALE_SMOOTH); zoomedIcon = new ImageIcon(scaledImage); icons.put(zoom, zoomedIcon); g.dispose(); } return zoomedIcon; }
@Override public Icon getIcon(final NodeModel node) { if(uiIcon.getUrl().getPath().endsWith(".svg")) { final Quantity<LengthUnits> iconHeight = IconController.getController().getIconSize(node); return IconFactory.getInstance().getIcon(this, iconHeight.zoomBy(zoom)); } else { return getZoomedBitmapIcon(); } }
private JButton[] createButtonRow(final int modifiers) { final JButton[] buttons = new JButton[BUTTON_NUMBER]; for (int i = 0; i < BUTTON_NUMBER; i++) { final String name = "f" + (i + 1) + ".png"; final JButton button = buttons[i] = new JButton(toImageIcon(IconStoreFactory.ICON_STORE.getUIIcon(name).getIcon())) { /** * */ private static final long serialVersionUID = 1L; @Override protected void configurePropertiesFromAction(final Action a) { } }; button.setFont(BUTTON_FONT); button.setFocusable(false); button.setBorder(BorderFactory.createEtchedBorder()); if (System.getProperty("os.name").startsWith("Mac OS")) { button.setBorderPainted(false); } KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F1 + i, modifiers); setAcceleratorAction(button, ks); } return buttons; }