예제 #1
0
  public Dimension requestResize(
      final Dimension newSize,
      final RequestOrigin origin,
      int cursorY,
      JediTerminal.ResizeHandler resizeHandler) {
    if (!newSize.equals(myTermSize)) {
      myTerminalTextBuffer.lock();
      try {
        myTerminalTextBuffer.resize(newSize, origin, cursorY, resizeHandler, mySelection);
        myTermSize = (Dimension) newSize.clone();

        final Dimension pixelDimension = new Dimension(getPixelWidth(), getPixelHeight());

        setPreferredSize(pixelDimension);
        if (myTerminalPanelListener != null) {
          myTerminalPanelListener.onPanelResize(pixelDimension, origin);
        }
        SwingUtilities.invokeLater(
            new Runnable() {
              @Override
              public void run() {
                updateScrolling();
              }
            });
      } finally {
        myTerminalTextBuffer.unlock();
      }
    }

    return new Dimension(getPixelWidth(), getPixelHeight());
  }
예제 #2
0
 static {
   Toolkit tk = Toolkit.getDefaultToolkit();
   Dimension d = tk.getBestCursorSize(32, 32);
   int colors = tk.getMaximumCursorColors();
   if (!d.equals(new Dimension(0, 0)) && (colors != 0)) {
     CursorFactory c = new CursorFactory();
     URL uImage = c.getClass().getResource("/images/zoom.gif");
     Image image = tk.getImage(uImage);
     if (image != null) {
       try {
         // 		    System.out.println("loaded");
         zoomC = tk.createCustomCursor(image, new Point(16, 16), "crosshair cursor");
       } catch (Exception e) {
       }
     }
     uImage = c.getClass().getResource("/images/move.gif");
     image = tk.getImage(uImage);
     if (image != null) {
       try {
         // 		    System.out.println("loaded");
         moveC = tk.createCustomCursor(image, new Point(16, 16), "crosshair cursor");
       } catch (Exception e) {
       }
     }
   }
 }
예제 #3
0
 /** The field view component needs to be redisplayed. Copy the internal image to screen. */
 public void paintComponent(Graphics g) {
   if (fieldImage != null) {
     Dimension currentSize = getSize();
     if (size.equals(currentSize)) {
       g.drawImage(fieldImage, 0, 0, null);
     } else {
       // Rescale the previous image.
       g.drawImage(fieldImage, 0, 0, currentSize.width, currentSize.height, null);
     }
   }
 }
예제 #4
0
파일: LJ3MDApp.java 프로젝트: eskilj/mvp
 /**
  * Prepare a buffer for the image, return if the canvas is ready Only need to call this when the
  * size of the canvas is changed, Since we automatically detect the size change in paint() only
  * call this on start
  */
 public boolean newImgBuf() {
   Dimension sz = getSize();
   if (sz.width == 0 || sz.height == 0) return false;
   // quit if the current image already has the right size
   if (img != null && imgG != null && sz.equals(imgSize)) return true;
   img = createImage(sz.width, sz.height);
   if (imgG != null) imgG.dispose();
   imgG = img.getGraphics();
   imgSize = sz;
   return true;
 }
예제 #5
0
  /**
   * Sets the size of the Popup window using a <code>Dimension</code> object. This is equivalent to
   * <code>setPreferredSize(d)</code>.
   *
   * @param d the <code>Dimension</code> specifying the new size of this component.
   * @beaninfo description: The size of the popup menu
   */
  public void setPopupSize(Dimension d) {
    Dimension oldSize = getPreferredSize();

    setPreferredSize(d);
    if (popup != null) {
      Dimension newSize = getPreferredSize();

      if (!oldSize.equals(newSize)) {
        popup = getPopup();
      }
    }
  }
예제 #6
0
 public void update(Graphics g) {
   Dimension newSize = getSize();
   if (size.equals(newSize)) {
     // Erase old box
     g.setColor(getBackground());
     g.drawRect(mx, my, (size.width / 10) - 1, (size.height / 10) - 1);
   } else {
     size = newSize;
     g.clearRect(0, 0, size.width, size.height);
   }
   // Calculate new position
   mx = (int) (Math.random() * 1000) % (size.width - (size.width / 10));
   my = (int) (Math.random() * 1000) % (size.height - (size.height / 10));
   paint(g);
 }
예제 #7
0
    /**
     * Prepare for a new round of painting. Since the component may be resized, compute the scaling
     * factor again.
     */
    public void preparePaint() {
      if (!size.equals(getSize())) { // if the size has changed...
        size = getSize();
        fieldImage = fieldView.createImage(size.width, size.height);
        g = fieldImage.getGraphics();

        xScale = size.width / gridWidth;
        if (xScale < 1) {
          xScale = GRID_VIEW_SCALING_FACTOR;
        }
        yScale = size.height / gridHeight;
        if (yScale < 1) {
          yScale = GRID_VIEW_SCALING_FACTOR;
        }
      }
    }
예제 #8
0
  /** return the hierarchies that are on the slicer axis (all that are not visible) */
  public static Set getSlicerHierarchies(OlapModel model) throws OlapException {
    Set visible = getVisibleDimensions(model);

    /* Get dimensions and hierarchies on the slicer */

    Axis slicer = model.getResult().getSlicer();
    Set selectedSlicerDims = new HashSet();
    Set selectedSlicerHiers = new HashSet();

    List positions = slicer.getPositions();

    for (Iterator iter = positions.iterator(); iter.hasNext(); ) {
      Position pos = (Position) iter.next();
      Member[] posMembers = pos.getMembers();
      for (int i = 0; i < posMembers.length; i++) {
        Hierarchy hier = posMembers[i].getLevel().getHierarchy();
        Dimension dim = hier.getDimension();

        if (!selectedSlicerHiers.contains(hier)) selectedSlicerHiers.add(hier);

        if (!selectedSlicerDims.contains(dim)) selectedSlicerDims.add(dim);
      }
    }
    /* Return hierarchies that are not on the rows or columns and for the selected
     * members, return the selected hierarchy
     */
    Set slicerHiers = new HashSet();
    Dimension[] dims = model.getDimensions();
    for (int i = 0; i < dims.length; i++) {
      if (!visible.contains(dims[i])) {
        if (!selectedSlicerDims.contains(dims[i])) {
          slicerHiers.add(dims[i].getHierarchies()[0]);
        } else {
          for (Iterator it = selectedSlicerHiers.iterator(); it.hasNext(); ) {
            Hierarchy hier = (Hierarchy) it.next();
            Dimension dim = hier.getDimension();
            if (dim.equals(dims[i])) {
              slicerHiers.add(hier);
              break;
            }
          }
        }
      }
    }

    return slicerHiers;
  }
예제 #9
0
  private void invalidateIfNeeded() {
    if (myLabel.getRootPane() == null) return;

    Dimension d = myLabel.getSize();
    Dimension pref = myLabel.getPreferredSize();
    if (d != null && d.equals(pref)) {
      return;
    }

    setInactiveStateImage(null);

    myLabel.invalidate();

    if (myActionPanel != null) {
      myActionPanel.invalidate();
    }

    myTabs.revalidateAndRepaint(false);
  }
  /** Try matching the data formats and find common ones for concatenation. */
  public boolean tryMatch(ProcInfo pInfo[], int type, int trackID) {
    TrackControl tc = pInfo[0].tracksByType[type][trackID].tc;
    Format origFmt = tc.getFormat();
    Format newFmt, oldFmt;
    Format supported[] = tc.getSupportedFormats();

    for (int i = 0; i < supported.length; i++) {

      if (supported[i] instanceof AudioFormat) {
        // If it's not the original format, then for audio, we'll
        // only do linear since it's more accurate to compute the
        // audio times.
        if (!supported[i].matches(tc.getFormat())
            && !supported[i].getEncoding().equalsIgnoreCase(AudioFormat.LINEAR)) continue;
      }

      if (tryTranscode(pInfo, 1, type, trackID, supported[i])) {

        // We've found the right format to transcode all the
        // tracks to. We'll set it on the corresponding
        // TrackControl on each processor.

        for (int j = 0; j < pInfo.length; j++) {
          tc = pInfo[j].tracksByType[type][trackID].tc;
          oldFmt = tc.getFormat();
          newFmt = supported[i];

          // Check if it requires transcoding.
          if (!oldFmt.matches(newFmt)) {
            if (!transcodeMsg) {
              transcodeMsg = true;
              System.err.println(TRANSCODE_MSG);
            }

            System.err.println("- Transcoding: " + pInfo[j].ml);
            System.err.println("  " + oldFmt);
            System.err.println("           to:");
            System.err.println("  " + newFmt);
          }

          // For video, check if it requires scaling.
          if (oldFmt instanceof VideoFormat) {
            Dimension newSize = ((VideoFormat) origFmt).getSize();
            Dimension oldSize = ((VideoFormat) oldFmt).getSize();

            if (oldSize != null && !oldSize.equals(newSize)) {
              // It requires scaling.

              if (!transcodeMsg) {
                transcodeMsg = true;
                System.err.println(TRANSCODE_MSG);
              }
              System.err.println("- Scaling: " + pInfo[j].ml);
              System.err.println("  from: " + oldSize.width + " x " + oldSize.height);
              System.err.println("  to: " + newSize.width + " x " + newSize.height);
              newFmt =
                  (new VideoFormat(null, newSize, Format.NOT_SPECIFIED, null, Format.NOT_SPECIFIED))
                      .intersects(newFmt);
            }
          }
          tc.setFormat(newFmt);
        }

        return true;
      }
    }

    return false;
  }