Package javax.swing

Examples of javax.swing.ImageIcon


   
   
    public static ImageIcon getIcon(Element element, String tag) throws InvalidValueException {
        String s = getString(element, tag);
        try {
            return new ImageIcon(s);
        } catch (Exception e) {
            throw new InvalidValueException(tag, s);
        }       
    }    
View Full Code Here


    public JToolBar getPolyGUI(boolean includeEnclose, boolean includeAdd,
                               boolean includeDelete) {
        JToolBar buttonBox = new GridBagToolBar();

        URL url;
        ImageIcon imageIcon;
        if (polygonButton == null) {
            url = getImageURL("enclosepoly.gif");
            imageIcon = new ImageIcon(url);
            polygonButton = new JToggleButton(imageIcon);
            polygonButton.setToolTipText(i18n.get(EditableOMPoly.class,
                    "polygonButton.tooltip",
                    "Automatically link first and last nodes"));
        }

        polygonButton.setSelected(isEnclosed());
        polygonButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (getStateMachine().getState() instanceof GraphicSelectedState) {
                    enclose(((JToggleButton) e.getSource()).isSelected());
                } else {
                    setEnclosed(((JToggleButton) e.getSource()).isSelected());
                }
            }
        });
        if (includeEnclose) {
            buttonBox.add(polygonButton);
        }

        if (addButton == null) {
            url = getImageURL("addpoint.gif");
            imageIcon = new ImageIcon(url);
            addButton = new JButton(imageIcon);
            addButton.setToolTipText(i18n.get(EditableOMPoly.class,
                    "addButton.tooltip",
                    "Add a node to the polygon"));
        }
        addButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ((PolyStateMachine) stateMachine).setAddNode();
                enablePolygonEditButtons(false);
            }
        });
        addButton.setEnabled(false);
        if (includeAdd) {
            buttonBox.add(addButton);
        }

        if (deleteButton == null) {
            url = getImageURL("deletepoint.gif");
            imageIcon = new ImageIcon(url);
            deleteButton = new JButton(imageIcon);
            deleteButton.setToolTipText(i18n.get(EditableOMPoly.class,
                    "deleteButton.tooltip",
                    "Delete a node from the polygon"));
        }
View Full Code Here

     * Method createPoint. Renders a Point.
     *
     * @param myPoint
     */
    protected OMGraphic createPoint(MysqlPoint myPoint) {
        ImageIcon actualPointSymbol = new ImageIcon(pointSymbol);
        OMRaster ompoint = new OMRaster((float) myPoint.getNorthings(), (float) myPoint.getEastings(), actualPointSymbol);

        drawingAttributes.setTo(ompoint);

        return ompoint;
View Full Code Here

    public static Cursor create(String resource, Point hotspot, String name) {
        Cursor cursor = DEFAULT;
        try {

            URL url = (new EOMGCursors()).getClass().getResource(resource);
            ImageIcon image = new ImageIcon(url);
            cursor = Toolkit.getDefaultToolkit()
                    .createCustomCursor(image.getImage(), hotspot, name);

        } catch (IndexOutOfBoundsException ioobe) {
            Debug.error("LineStateMachine creating cursor:\n "
                    + ioobe.getMessage());
        }
View Full Code Here

        Box leftBox = Box.createVerticalBox();
        Box innerBox = Box.createHorizontalBox();

        try {
            URL url = PropUtils.getResourceOrFileOrURL(this, snapshotIconName);
            ImageIcon snapshotIcon = new ImageIcon(url);

            url = PropUtils.getResourceOrFileOrURL(this, totalScenarioIconName);
            ImageIcon totalScenarioIcon = new ImageIcon(url);

            timeWrapToggle = new JToggleButton(totalScenarioIcon, timeWrap);
            timeWrapToggle.setSelectedIcon(snapshotIcon);
            timeWrapToggle.setActionCommand(SCENARIO_MODE_CMD);
            timeWrapToggle.addActionListener(this);
            timeWrapToggle.setToolTipText("Wrap Scenario Time Scale");
            // jtb.add(timeWrapToggle);
            innerBox.add(timeWrapToggle);

        } catch (MalformedURLException murle) {
            Debug.error("ScenarioGraphicLoader " + getName() + ":"
                    + murle.getMessage());
        } catch (NullPointerException npe) {
            Debug.error("ScenarioGraphicLoader " + getName() + ":"
                    + npe.getMessage());
        }

        timerControl = new TimerControlButtonPanel(this);
        // jtb.add(timerControl);
        innerBox.add(timerControl);
        rightBox.add(innerBox);

        pcs.addPropertyChangeListener(TIMER_RUNNING_STATUS, timerControl);

        String runningStatus = timer.isRunning() ? (getClockDirection() > 0 ? TIMER_FORWARD
                : TIMER_BACKWARD)
                : TIMER_STOPPED;
        pcs.firePropertyChange(TIMER_RUNNING_STATUS, null, runningStatus);

        timerRateControl = new TimerRateComboBox(this);
        timerRateControl.setToolTipText("Change clock rate for Scenario");

        Iterator it = timerRates.iterator();
        while (it.hasNext()) {
            TimerRateHolder trh = (TimerRateHolder) it.next();
            timerRateControl.add(trh.label, trh.clock, trh.pace);
        }

        int si = timerRates.size() / 2;
        if (si > 0) {
            timerRateControl.setSelectedIndex(si);
        }

        // jtb.add(timerRateControl);
        rightBox.add(timerRateControl);

        timeSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 0);
        timeSliderSupport = new TimeSliderSupport(timeSlider, this, startTime, endTime);
        // jtb.add(timeSlider);
        leftBox.add(timeSlider);

        timeLabel = new JLabel(" ", SwingConstants.CENTER);
        java.awt.Font defaultFont = timeLabel.getFont();
        timeLabel.setFont(new java.awt.Font(defaultFont.getName(), defaultFont.getStyle(), 10));
        // jtb.add(timeLabel);
        leftBox.add(timeLabel);

        URL url = ScenarioGraphicLoader.class.getResource("path.png");
        ImageIcon icon = new ImageIcon(url);

        JToggleButton modeButton = new JToggleButton(icon, mode == TOTAL_SCENARIO_MODE);
        modeButton.setToolTipText((mode == TOTAL_SCENARIO_MODE ? "Hide"
                : "Show")
                + " scenario paths on " + getName());
View Full Code Here

            URL fileURL = getFileURL(code);
            if (Debug.debugging("symbology")) {
                Debug.output("SVGSymbolImageMaker: Trying to create " + fileURL);
            }
            rasterizer = new SVGRasterizer(fileURL);
            return new ImageIcon(rasterizer.createBufferedImage(di));
        } catch (TranscoderException e) {
            Debug.output("FYI (exception handled):");
            e.printStackTrace();
        } catch (IOException e) {
            Debug.output("FYI (exception handled):");
View Full Code Here

            frame.addWindowListener(new WindowAdapter() {
                public void windowClosed(WindowEvent e) {
                    System.exit(0);
                }
            });
            frame.getContentPane().add(new JLabel(new ImageIcon(bi)));
            frame.pack();
            frame.setVisible(true);

        } catch (TranscoderException e2) {
            e2.printStackTrace();
View Full Code Here

    TableRow row,
    String key)
    throws GUIException {

    Label label = new Label(null, null);
    ImageIcon icon = (ImageIcon) value;
    Image inImage = icon.getImage();

    /* Resize the image */
    double scale = (double) maxImageSize / (double) inImage.getHeight(null);

    if (inImage.getWidth(null) > inImage.getHeight(null)) {
      scale = (double) maxImageSize / (double) inImage.getWidth(null);
    }
    int scaledW = (int) (scale * inImage.getWidth(null));
    int scaledH = (int) (scale * inImage.getHeight(null));
    BufferedImage outImage = new BufferedImage(scaledW, scaledH, BufferedImage.TYPE_INT_RGB);
    AffineTransform tx = new AffineTransform();

    if (scale < 1.0d) {
      tx.scale(scale, scale);
    }

    Color bgColor = null;
    Graphics2D g2d = outImage.createGraphics();
    g2d.setColor(bgColor);
    g2d.fillRect(0, 0, scaledW, scaledH);
    g2d.drawImage(inImage, tx, null);
    g2d.dispose();

    label.setIcon(new ImageIcon(outImage));
    label.setProperty("horizontalAlignment", new Integer(JLabel.CENTER));
    label.setProperty("opaque", Boolean.TRUE);
    return label;
  }
View Full Code Here

        className = classname;
        editableClassName = editableclassname;
        prettyName = prettyname;
        URL url = this.getClass().getResource(iconname);
        if (url != null) {
            icon = new ImageIcon(url);
        }
    }
View Full Code Here

     * @param command String command name
     *
     */
    protected JButton getButton(String name, String info, String command) {
        URL url = NavigatePanel.class.getResource(name);
        ImageIcon icon = new ImageIcon(url, info);
        JButton b = new JButton(icon);
        b.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
        b.setToolTipText(info);
        b.setMargin(new Insets(0, 0, 0, 0));
        b.setActionCommand(command);
        b.addActionListener(this);
        b.setBorderPainted(Debug.debugging("layout"));
View Full Code Here

TOP

Related Classes of javax.swing.ImageIcon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.