Exemplo n.º 1
0
  public JPanel getSlicePanel() {

    final JPanel framePanel = new JPanel();
    framePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    framePanel.setAlignmentY(Component.TOP_ALIGNMENT);
    framePanel.setLayout(new BoxLayout(framePanel, BoxLayout.Y_AXIS));
    framePanel.setBorder(
        BorderFactory.createCompoundBorder(
            spaceY,
            new TitledBorder(
                null,
                Messages.getString("ImageTool.frame"), // $NON-NLS-1$
                TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION,
                TITLE_FONT,
                TITLE_COLOR)));

    ActionState sequence = EventManager.getInstance().getAction(ActionW.SCROLL_SERIES);
    if (sequence instanceof SliderCineListener) {
      SliderCineListener cineAction = (SliderCineListener) sequence;
      final JSliderW frameSlider = cineAction.createSlider(4, true);
      framePanel.add(frameSlider.getParent());

      final JPanel panel_3 = new JPanel();
      panel_3.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 3));
      final JLabel speedLabel = new JLabel();
      speedLabel.setText(
          Messages.getString("ImageTool.cine_speed") + StringUtil.COLON); // $NON-NLS-1$
      panel_3.add(speedLabel);

      final JSpinner speedSpinner = new JSpinner(cineAction.getSpeedModel());
      JMVUtils.formatCheckAction(speedSpinner);
      panel_3.add(speedSpinner);
      final JButton startButton = new JButton();
      startButton.setActionCommand(ActionW.CINESTART.cmd());
      startButton.setPreferredSize(JMVUtils.getBigIconButtonSize());
      startButton.setToolTipText(Messages.getString("ImageTool.cine_start")); // $NON-NLS-1$
      startButton.setIcon(
          new ImageIcon(
              MouseActions.class.getResource(
                  "/icon/22x22/media-playback-start.png"))); //$NON-NLS-1$
      startButton.addActionListener(EventManager.getInstance());
      panel_3.add(startButton);
      cineAction.registerActionState(startButton);

      final JButton stopButton = new JButton();
      stopButton.setActionCommand(ActionW.CINESTOP.cmd());
      stopButton.setPreferredSize(JMVUtils.getBigIconButtonSize());
      stopButton.setToolTipText(Messages.getString("ImageTool.cine_stop")); // $NON-NLS-1$
      stopButton.setIcon(
          new ImageIcon(
              MouseActions.class.getResource(
                  "/icon/22x22/media-playback-stop.png"))); //$NON-NLS-1$
      stopButton.addActionListener(EventManager.getInstance());
      panel_3.add(stopButton);
      cineAction.registerActionState(stopButton);
      framePanel.add(panel_3);
    }
    return framePanel;
  }
Exemplo n.º 2
0
  @Override
  public void process() throws Exception {
    RenderedImage source = (RenderedImage) params.get(INPUT_IMG);
    RenderedImage result = source;
    Rectangle area = (Rectangle) params.get(P_AREA);

    if (area == null) {
      LOGGER.warn("Cannot apply \"{}\" because a parameter is null", OP_NAME); // $NON-NLS-1$
    } else {
      area =
          area.intersection(
              new Rectangle(
                  source.getMinX(), source.getMinY(), source.getWidth(), source.getHeight()));
      if (area.width > 1 && area.height > 1) {
        ParameterBlock pb = new ParameterBlock();
        pb.addSource(source);
        pb.add((float) area.x).add((float) area.y);
        pb.add((float) area.width).add((float) area.height);
        result = JAI.create("crop", pb, null); // $NON-NLS-1$

        if (JMVUtils.getNULLtoFalse(params.get(P_SHIFT_TO_ORIGIN))) {
          float diffw = source.getMinX() - result.getMinX();
          float diffh = source.getMinY() - result.getMinY();
          if (diffw != 0.0f || diffh != 0.0f) {
            pb = new ParameterBlock();
            pb.addSource(result);
            pb.add(diffw);
            pb.add(diffh);
            result = JAI.create("translate", pb, null); // $NON-NLS-1$
          }
        }
      }
    }
    params.put(OUTPUT_IMG, result);
  }
Exemplo n.º 3
0
 public JPanel getTransformPanel() {
   final JPanel transform = new JPanel();
   transform.setAlignmentY(Component.TOP_ALIGNMENT);
   transform.setAlignmentX(Component.LEFT_ALIGNMENT);
   transform.setLayout(new BoxLayout(transform, BoxLayout.Y_AXIS));
   transform.setBorder(
       BorderFactory.createCompoundBorder(
           spaceY,
           new TitledBorder(
               null,
               Messages.getString("ImageTool.transform"), // $NON-NLS-1$
               TitledBorder.DEFAULT_JUSTIFICATION,
               TitledBorder.DEFAULT_POSITION,
               TITLE_FONT,
               TITLE_COLOR)));
   ActionState zoomAction = EventManager.getInstance().getAction(ActionW.ZOOM);
   if (zoomAction instanceof SliderChangeListener) {
     final JSliderW zoomSlider = ((SliderChangeListener) zoomAction).createSlider(0, true);
     JMVUtils.setPreferredWidth(zoomSlider, 100);
     transform.add(zoomSlider.getParent());
   }
   ActionState rotateAction = EventManager.getInstance().getAction(ActionW.ROTATION);
   if (rotateAction instanceof SliderChangeListener) {
     final JSliderW rotationSlider = ((SliderChangeListener) rotateAction).createSlider(4, true);
     JMVUtils.setPreferredWidth(rotationSlider, 100);
     transform.add(rotationSlider.getParent());
   }
   ActionState flipAction = EventManager.getInstance().getAction(ActionW.FLIP);
   if (flipAction instanceof ToggleButtonListener) {
     JPanel pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 3));
     pane.add(
         ((ToggleButtonListener) flipAction)
             .createCheckBox(Messages.getString("ImageTool.flip"))); // $NON-NLS-1$
     transform.add(pane);
   }
   return transform;
 }
Exemplo n.º 4
0
 public LabelPrefView(ViewSetting viewSetting) {
   super(Messages.getString("LabelPrefView.font")); // $NON-NLS-1$
   if (viewSetting == null) {
     throw new IllegalArgumentException("ViewSetting cannot be null"); // $NON-NLS-1$
   }
   this.viewSetting = viewSetting;
   setComponentPosition(5);
   setBorder(new EmptyBorder(15, 10, 10, 10));
   try {
     JMVUtils.setList(
         jComboName,
         Messages.getString("LabelPrefView.default"),
         GraphicsEnvironment.getLocalGraphicsEnvironment() // $NON-NLS-1$
             .getAvailableFontFamilyNames());
     jbInit();
     initialize();
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
Exemplo n.º 5
0
  public JPanel getWindowLevelPanel() {

    final JPanel winLevelPanel = new JPanel();
    winLevelPanel.setAlignmentY(Component.TOP_ALIGNMENT);
    winLevelPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    winLevelPanel.setLayout(new BoxLayout(winLevelPanel, BoxLayout.Y_AXIS));
    winLevelPanel.setBorder(
        BorderFactory.createCompoundBorder(
            spaceY,
            new TitledBorder(
                null,
                Messages.getString("ImageTool.wl"), // $NON-NLS-1$
                TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION,
                TITLE_FONT,
                TITLE_COLOR)));
    ActionState winAction = EventManager.getInstance().getAction(ActionW.WINDOW);
    if (winAction instanceof SliderChangeListener) {
      final JSliderW windowSlider = ((SliderChangeListener) winAction).createSlider(4, true);
      // windowSlider.setMajorTickSpacing((largestWindow - smallestWindow) / 4);
      JMVUtils.setPreferredWidth(windowSlider, 100);
      winLevelPanel.add(windowSlider.getParent());
    }
    ActionState levelAction = EventManager.getInstance().getAction(ActionW.LEVEL);
    if (levelAction instanceof SliderChangeListener) {
      final JSliderW levelSlider = ((SliderChangeListener) levelAction).createSlider(4, true);
      levelSlider.setMajorTickSpacing(
          (ImageViewerEventManager.LEVEL_LARGEST - ImageViewerEventManager.LEVEL_SMALLEST) / 4);
      JMVUtils.setPreferredWidth(levelSlider, 100);
      winLevelPanel.add(levelSlider.getParent());
    }
    ActionState presetAction = EventManager.getInstance().getAction(ActionW.PRESET);
    if (presetAction instanceof ComboItemListener) {
      final JPanel panel_3 = new JPanel();
      panel_3.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 3));
      final JLabel presetsLabel = new JLabel();
      panel_3.add(presetsLabel);
      presetsLabel.setText(
          Messages.getString("ImageTool.preset") + StringUtil.COLON); // $NON-NLS-1$
      final JComboBox presetComboBox = ((ComboItemListener) presetAction).createCombo(160);
      presetComboBox.setMaximumRowCount(10);
      panel_3.add(presetComboBox);
      winLevelPanel.add(panel_3);
    }
    ActionState lutAction = EventManager.getInstance().getAction(ActionW.LUT);
    if (lutAction instanceof ComboItemListener) {
      final JPanel panel_4 = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 3));
      final JLabel lutLabel = new JLabel();
      lutLabel.setText(Messages.getString("ImageTool.lut") + StringUtil.COLON); // $NON-NLS-1$
      panel_4.add(lutLabel);
      final JComboBox lutcomboBox = ((ComboItemListener) lutAction).createCombo(140);
      panel_4.add(lutcomboBox);
      ActionState invlutAction = EventManager.getInstance().getAction(ActionW.INVERT_LUT);
      if (invlutAction instanceof ToggleButtonListener) {
        panel_4.add(
            ((ToggleButtonListener) invlutAction)
                .createCheckBox(Messages.getString("ImageTool.inverse"))); // $NON-NLS-1$
      }
      winLevelPanel.add(panel_4);
    }
    ActionState filterAction = EventManager.getInstance().getAction(ActionW.FILTER);
    if (filterAction instanceof ComboItemListener) {
      final JPanel panel_4 = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 3));
      final JLabel lutLabel = new JLabel();
      lutLabel.setText(Messages.getString("ImageTool.filter")); // $NON-NLS-1$
      panel_4.add(lutLabel);
      final JComboBox filtercomboBox = ((ComboItemListener) filterAction).createCombo(160);
      panel_4.add(filtercomboBox);
      winLevelPanel.add(panel_4);
    }
    return winLevelPanel;
  }