コード例 #1
0
  @Override
  public void showFeedback() {
    createFeedback();

    myBounds =
        myContext.getTransformedRectangle(
            myComponent.getBounds(myContext.getArea().getFeedbackLayer()));
    myBounds.width = Math.max(myBounds.width, 0);
    myBounds.height = Math.max(myBounds.height, 0);

    int direction = myContext.getResizeDirection();

    if ((direction & Position.EAST) != 0) {
      if (!snapToWidth(myBounds, myWrapSize, SNAP_DELTA)) {
        snapToWidth(myBounds, myFillSize, SNAP_DELTA);
      }
    }
    if ((direction & Position.SOUTH) != 0) {
      if (!snapToHeight(myBounds, myWrapSize, SNAP_DELTA)) {
        snapToHeight(myBounds, myFillSize, SNAP_DELTA);
      }
    }

    myFeedback.setBounds(myBounds);

    myTextFeedback.clear();

    addTextSize(myStaticWidth, myBounds.width, myWrapSize.width, myFillSize.width);
    myTextFeedback.append(" x ", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
    addTextSize(myStaticHeight, myBounds.height, myWrapSize.height, myFillSize.height);

    myTextFeedback.locationTo(myContext.getLocation(), 15);
  }
コード例 #2
0
 private void addTextSize(String staticText, int size, int wrap, int fill) {
   if (staticText == null) {
     if (size == wrap) {
       myTextFeedback.snap("wrap_content");
     } else if (size == fill) {
       myTextFeedback.snap("match_parent");
     } else {
       myTextFeedback.append(Integer.toString(size));
       myTextFeedback.dimension("dp");
     }
   } else {
     if (staticText.length() > 2) {
       int index = staticText.length() - 2;
       String dimension = staticText.substring(index);
       if (ArrayUtil.indexOf(ResourceRenderer.DIMENSIONS, dimension) != -1) {
         myTextFeedback.append(staticText.substring(0, index));
         myTextFeedback.dimension(dimension);
       } else {
         myTextFeedback.append(staticText);
       }
     } else {
       myTextFeedback.append(staticText);
     }
   }
 }
コード例 #3
0
  private void createFeedback() {
    if (myFeedback == null) {
      FeedbackLayer layer = myContext.getArea().getFeedbackLayer();

      myFeedback = new RectangleFeedback(Color.blue, 2);
      layer.add(myFeedback);

      myTextFeedback = new TextFeedback();
      myTextFeedback.setBorder(new LineMarginBorder(0, 5, 3, 0));
      layer.add(myTextFeedback);
      layer.add(myWrapFeedback);
      layer.add(myFillFeedback);

      layer.repaint();
    }
  }
コード例 #4
0
 @Override
 public void addTextInfo(TextFeedback feedback) {
   feedback.append("layout:" + (myHorizontal ? "width " : "height "));
   feedback.snap("wrap_content");
 }