示例#1
0
  public static TextStyle getTextStyle(IGraphicalPart part, IStyleSelector ss) {
    Object cache = MindMapUtils.getCache(part, MindMapUI.CACHE_TEXT_STYLE);
    if (cache instanceof TextStyle) return (TextStyle) cache;

    TextStyleData data = getTextStyleData(part, ss, null);
    return data.createTextStyle();
  }
 public void decorateMoveInRequest(
     IBranchPart targetParent,
     ParentSearchKey childKey,
     IBranchPart sourceParent,
     Request request) {
   RowHead rowHead =
       (RowHead) MindMapUtils.getCache(targetParent, Spreadsheet.KEY_INSERTION_ROW_HEAD);
   if (rowHead != null) {
     request.setParameter(
         MindMapUI.PARAM_PROPERTY_PREFIX + Core.Labels, new HashSet<String>(rowHead.getLabels()));
   } else {
     request.setParameter(MindMapUI.PARAM_PROPERTY_PREFIX + Core.Labels, new HashSet<String>());
   }
 }
示例#3
0
  public static TextStyleData getTextStyleData(
      IGraphicalPart part, IStyleSelector ss, TextStyleData defaultData) {
    Object cache = MindMapUtils.getCache(part, MindMapUI.CACHE_TEXT_STYLE);
    if (cache instanceof TextStyleData) return (TextStyleData) cache;

    TextStyleData data;
    if (defaultData == null) {
      data = new TextStyleData();
      defaultData = data;
    } else {
      data = new TextStyleData(defaultData);
    }

    String name = getString(part, ss, Styles.FontFamily, defaultData.name);
    if (Styles.SYSTEM.equals(name)) {
      name = JFaceResources.getDefaultFont().getFontData()[0].getName();
    }
    data.name = name;

    data.height = getInteger(part, ss, Styles.FontSize, defaultData.height);

    String weight = getString(part, ss, Styles.FontWeight, null);
    if (weight != null) {
      data.bold = weight.contains(Styles.FONT_WEIGHT_BOLD);
    }

    String style = getString(part, ss, Styles.FontStyle, null);
    if (style != null) {
      data.italic = style.contains(Styles.FONT_STYLE_ITALIC);
    }

    RGB c = getRGB(part, ss, Styles.TextColor, null);
    if (c != null) {
      data.color = c;
    }

    String decoration = getString(part, ss, Styles.TextDecoration, null);
    if (decoration != null) {
      data.underline = decoration.contains(Styles.TEXT_DECORATION_UNDERLINE);
      data.strikeout = decoration.contains(Styles.TEXT_DECORATION_LINE_THROUGH);
    }

    int align = getAlignValue(part, ss, Styles.TextAlign);
    data.align = align;
    return data;
  }
示例#4
0
  private void ensurePosition() {
    if (this.left != null && this.width != null) return;

    int lineWidth = getOwnedChart().getLineWidth();
    int index = getOwnedChart().getColumnIndex(this);
    IInsertion ins =
        (IInsertion)
            MindMapUtils.getCache(getOwnedChart().getTitle(), Spreadsheet.CACHE_COLUMN_INSERTION);
    int x;
    if (index == 0) {

      x =
          getOwnedChart().getTitle().getFigure().getBounds().x
              + lineWidth
              + getOwnedChart().getRowHeadWidth()
              + lineWidth
              + getOwnedChart().getMinorSpacing();
    } else {
      Column prev = getOwnedChart().getColumn(index - 1);
      x = prev.getRight() + lineWidth;
    }
    if (ins != null && ins.getIndex() == index) {
      x += ins.getSize().width + getOwnedChart().getMinorSpacing() + lineWidth;
    }
    this.left = Integer.valueOf(x);

    int w;
    int numCols = getOwnedChart().getNumColumns();
    if (index == numCols - 1) {
      int right = getOwnedChart().getTitle().getFigure().getBounds().right();
      //            System.out.println(head.toString() + ": (" + left.intValue() + ","
      //                    + right + ")");
      if (ins != null && ins.getIndex() == numCols) {
        right -= ins.getSize().width + getOwnedChart().getMinorSpacing() + lineWidth;
      }
      w = right - lineWidth - this.left.intValue();
    } else {
      int headWidth = head.getPrefSize().width;
      w = Math.max(headWidth, getPrefCellWidth()) + getOwnedChart().getMinorSpacing();
    }
    this.width = Integer.valueOf(w);
  }
  protected void fillSubBranches(
      IBranchPart branch, List<IBranchPart> subBranches, LayoutInfo info) {
    Rectangle area = info.getCheckedClientArea();

    Column2 col = getColumn(branch);
    Chart2 chart = col.getOwnedChart();
    int lineWidth = chart.getLineWidth();
    int cellSpacing = chart.getMinorSpacing();
    int itemSpacing = col.getMinorSpacing();

    IInsertion insertion = getCurrentInsertion(branch);
    RowHead insHead = (RowHead) MindMapUtils.getCache(branch, Spreadsheet.KEY_INSERTION_ROW_HEAD);

    int startX = info.getReference().x - col.getPrefCellWidth() / 2;
    int y = area.y + chart.getColHeadHeight() + cellSpacing / 2 + lineWidth;
    List<Row2> rows = chart.getRows();
    IInsertion rowIns =
        (IInsertion) MindMapUtils.getCache(chart.getTitle(), Spreadsheet.CACHE_ROW_INSERTION);
    for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) {
      if (rowIns != null && rowIns.getIndex() == rowIndex) {
        y += rowIns.getSize().height + chart.getMinorSpacing() + lineWidth;
      }

      Row2 row = rows.get(rowIndex);
      int x = startX;
      boolean insertionInRow = insertion != null && row.getHead().equals(insHead);
      Cell2 cell = col.findCellByRow(row);
      if (cell != null) {
        info.add(new Rectangle(x, y, col.getPrefCellWidth(), cell.getContentHeight()));
        List<Item2> items = cell.getItems();
        int num = items.size();
        int itemY = y;
        for (int i = 0; i < num; i++) {
          Item2 item = items.get(i);
          if (insertionInRow && insertion.getIndex() == i) {
            Rectangle r = insertion.createRectangle(x, y);
            info.add(r);
            itemY += r.height + itemSpacing;
          }
          IBranchPart child = item.getBranch();
          IFigure childFigure = child.getFigure();
          Dimension size = childFigure.getPreferredSize();

          int bh = 0;
          if (!branch.getBoundaries().isEmpty()) {
            for (IBoundaryPart boundary : branch.getBoundaries()) {
              List<IBranchPart> enclosingBranches = boundary.getEnclosingBranches();
              if (child.equals(enclosingBranches.get(0))) {
                bh = boundary.getFigure().getInsets().top;
                if (boundary.getTitle() != null && boundary.getTitle().getFigure() != null) {
                  Dimension s = boundary.getTitle().getFigure().getPreferredSize();
                  bh = Math.max(bh, s.height);
                }
                List<ITopic> topics = boundary.getBoundary().getEnclosingTopics();
                if (topics.size() > 1) {
                  itemY += bh;
                }
                bh = 0;
              }
              if (child.equals(enclosingBranches.get(enclosingBranches.size() - 1))) {
                bh = boundary.getFigure().getInsets().bottom;
              }
            }
          }

          Rectangle childBounds = new Rectangle(x, itemY, size.width, size.height + 10);
          info.put(childFigure, childBounds);
          itemY += size.height + itemSpacing + bh;
        }
        if (insertionInRow && insertion.getIndex() == num) {
          info.add(insertion.createRectangle(x, y));
        }
      } else if (insertionInRow) {
        info.add(insertion.createRectangle(x, y));
      }
      y += row.getPrefCellHeight() + cellSpacing + lineWidth;
    }
    if (rowIns != null && rowIns.getIndex() == rows.size()) {
      info.add(new Rectangle(startX, y, rowIns.getSize().width, 1));
    }
  }