Package tools.common

Examples of tools.common.JImageComponent


        });

    this.add(leftPanel, BorderLayout.WEST);

    JPanel mainPanel = new JPanel(new BorderLayout());
    JImageComponent imageComp = new JImageComponent(true);
    imageComp
        .setLegend(new String[] {
            "Image panel. Use one of the following to show an image:",
            "\t* Right-click to paste an image from the clipboard",
            "\t* Drag and drop an image file from local disk or another app",
            "\t* Drag and drop a URL pointing to an image" });

    imageComp.addPropertyChangeListener("selectedColor",
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            Color selectedImageColor = (Color) evt.getNewValue();
            JColorComponent selectedColorComp = colorSchemeComp
View Full Code Here


    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.setLayout(new GridLayout(1, 2));

    final JImageComponent jic = new JImageComponent(false);
    jic
        .setLegend(new String[] { "\tDrag and drop an image file from local disk" });
    jic.setBorder(new Border() {
      @Override
      public void paintBorder(Component c, Graphics g, int x, int y,
          int width, int height) {
        Graphics2D g2d = (Graphics2D) g.create();
        g2d.setColor(SubstanceLookAndFeel.getCurrentSkin(c)
            .getColorScheme(c, ColorSchemeAssociationKind.BORDER,
                ComponentState.ENABLED).getMidColor());
        g2d.drawLine(x + width - 2, y, x + width - 2, y + height - 1);
        g2d.setComposite(AlphaComposite.SrcOver.derive(0.8f));
        g2d.setColor(SubstanceLookAndFeel.getCurrentSkin(c)
            .getColorScheme(c, ColorSchemeAssociationKind.BORDER,
                ComponentState.ENABLED).getExtraLightColor()
            .brighter());
        g2d.drawLine(x + width - 1, y, x + width - 1, y + height - 1);
        g2d.dispose();
      }

      @Override
      public boolean isBorderOpaque() {
        return false;
      }

      @Override
      public Insets getBorderInsets(Component c) {
        return new Insets(0, 0, 0, 2);
      }
    });
    this.add(jic);

    final JElectrifiedImageComponent jeic = new JElectrifiedImageComponent(
        jic);

    JPanel electrifiedContainer = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(jeic,
        JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scroller.setBorder(new EmptyBorder(0, 0, 0, 0));
    electrifiedContainer.add(scroller, BorderLayout.CENTER);

    JButton saveElectrified = new JButton("save");
    saveElectrified.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            File originalFile = jic.getOriginalFile();
            if (originalFile != null) {
              jeic.save(originalFile);
            }
          }
        });
      }
    });
    JPanel controls = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    controls.add(saveElectrified);
    electrifiedContainer.add(controls, BorderLayout.SOUTH);

    this.add(electrifiedContainer);

    jic.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        if (e.getClickCount() == 2) {
          Point absPoint = jic.toOriginalImageCoords(e.getX(), e
              .getY());
          jeic.addZoomBubble(absPoint.x, absPoint.y, 80);
        }
      }
    });
View Full Code Here

TOP

Related Classes of tools.common.JImageComponent

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.