/** * add a content to layout and sets him positions * @param content * @param position */ public void add(Content content, Point2D position) { if(null == content) { throw new NullPointerException("Content can't be null"); } super.add(new RelativeContent(content, position)); }
/** * Defines how to draw element * * @param graphics */ @Override public final void draw(Graphics2D graphics) { layout.draw(graphics); }
/** * @return minimal bounds of this element */ public Rectangle2D getMinimalBounds() { return layout.getMinimalBounds(); }
/** * @see Content#draw(Graphics2D) */ @Override public final void draw(Graphics2D graphics) { Content content = null; Point2D offset = new Point2D.Double(0,0); Iterator<Content> iterator = contents.iterator(); if(iterator.hasNext()) { content = iterator.next(); content.draw(graphics, offset); } while(iterator.hasNext()) { offset = getNextOffset(offset, content); content = iterator.next(); content.draw(graphics, offset); separator.draw(graphics, getStartPointSeparator(offset), getEndPointSeparator(offset)); } }
/** * @see Content#refreshUp() */ @Override public final void refreshUp() { Rectangle2D minimalBounds = getMinimalBounds(); setWidth(minimalBounds.getWidth()); setHeight(minimalBounds.getHeight()); super.refreshUp(); }
/** * removes a content from layout * @param content */ public void remove(Content content) { if(null == content) { throw new NullPointerException("Content can't be null"); } content.removeParent(this); contents.remove(content); refresh(); }
/** * @param content * @return locations of the content relative to the inside layout */ public Point2D getLocation(Content content) { int index = contents.indexOf(content); Point2D offset = new Point2D.Double(0,0); for(int i = 0; i < index; ++i) { offset = getNextOffset(offset, contents.get(i)); } return offset; }
/** * @see Layout#remove(Content) */ @Override public void remove(Content content) { if(null == content) { return; } RelativeContent relativeContent = null; for (Content c: getContents()) { relativeContent = (RelativeContent)c; if(relativeContent.content.equals(content)) { super.remove(relativeContent); break; } } }
/** * Refresh all the elements in layout * * @see Content#refreshDown() */ @Override protected void refreshDown() { for (Content content: getContents()) { content.refreshDown(); } super.refreshDown(); }
/** * @see Content#refreshUp() */ @Override public final void refreshUp() { Rectangle2D minimalBounds = getMinimalBounds(); setHeight(minimalBounds.getHeight()); setWidth(minimalBounds.getWidth()); setContentsHeight(minimalBounds.getWidth()); super.refreshUp(); }
/** * add a content to layout * @param content */ public void add(Content content) { if(null == content) { throw new NullPointerException("Content can't be null"); } content.addParent(this); contents.add(content); refresh(); }
/** * @return minimal bounds of this element */ @Override public Rectangle2D getMinimalBounds() { Rectangle2D selfMinimalBounds = super.getMinimalBounds(); double maxX = selfMinimalBounds.getWidth(); double maxY = selfMinimalBounds.getHeight(); for (Content content: getContents()) { Rectangle2D rect = content.getMinimalBounds(); maxX = Math.max(maxX, rect.getMaxX()); maxY = Math.max(maxY, rect.getMaxY()); } return new Rectangle2D.Double(getX(),getY(),maxX,maxY); }
/** * @see Content#refreshUp() */ @Override public final void refreshUp() { Rectangle2D minimalBounds = getMinimalBounds(); setHeight(minimalBounds.getHeight()); setWidth(minimalBounds.getWidth()); setContentsWidth(minimalBounds.getWidth()); super.refreshUp(); }
public PaddingContent(Content content, double top, double left, double bottom, double right) { this.content = content; this.top = new EmptyContent(); this.left = new EmptyContent(); this.bottom = new EmptyContent(); this.right = new EmptyContent(); setTopPadding(top); setLeftPadding(left); setBottomPadding(bottom); setRightPadding(right); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.add(this.left); horizontalLayout.add(this.content); horizontalLayout.add(this.right); layout = new VerticalLayout(); layout.add(this.top); layout.add(horizontalLayout); layout.add(this.bottom); this.content.addParent(this); }
/** * @return minimal bounds of this element */ @Override public Rectangle2D getMinimalBounds() { Rectangle2D selfMinimalBounds = super.getMinimalBounds(); double width = 0; double height = 0; for (Content content: getContents()) { Rectangle2D contentMinimalBounds = content.getMinimalBounds(); width += contentMinimalBounds.getWidth(); if(height < contentMinimalBounds.getHeight()) { height = contentMinimalBounds.getHeight(); } } height = Math.max(height, selfMinimalBounds.getHeight()); width = Math.max(width, selfMinimalBounds.getWidth()); return new Rectangle2D.Double(getX(),getY(),width,height); }
/** * @return minimal bounds of this element */ @Override public Rectangle2D getMinimalBounds() { Rectangle2D selfMinimalBounds = super.getMinimalBounds(); double height = 0; double width = 0; for (Content content: getContents()) { Rectangle2D contentMinimalBounds = content.getMinimalBounds(); height += contentMinimalBounds.getHeight(); if(width < contentMinimalBounds.getWidth()) { width = contentMinimalBounds.getWidth(); } } height = Math.max(height, selfMinimalBounds.getHeight()); width = Math.max(width, selfMinimalBounds.getWidth()); return new Rectangle2D.Double(getX(),getY(),width,height); }