本文整理汇总了Java中org.eclipse.draw2d.Graphics.fillRectangle方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.fillRectangle方法的具体用法?Java Graphics.fillRectangle怎么用?Java Graphics.fillRectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.Graphics
的用法示例。
在下文中一共展示了Graphics.fillRectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
super.paintFigure(g);
Rectangle r = getBounds();
Rectangle square = new Rectangle(r.getLocation().getTranslated(0, r.height/4), new Dimension(r.width/2, r.height/2));
center = new Point(square.x + square.width/2, square.y + square.height/2);
g.setBackgroundColor(dirty ? PandionJConstants.Colors.HIGHLIGHT : PandionJConstants.Colors.VARIABLE_BOX);
g.fillRectangle(square);
g.setForegroundColor(ref.getRole() == Role.FIXED_VALUE ? PandionJConstants.Colors.CONSTANT : ColorConstants.black);
g.drawRectangle(square);
g.setBackgroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black);
g.fillOval(center.x-3, center.y-3, 7, 7);
if(isnull) {
g.setForegroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black);
Point dest = center.getTranslated(20, 0);
g.drawLine(center, dest);
g.drawLine(dest.getTranslated(-3, 5), dest.getTranslated(3, -5));
}
}
示例2: drawHorizontalTitleBar
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* rect는 타이틀 바를 그릴 사각형이다. 여기서는 이 사각형에 타이틀 바를 그린다.
* 타이틀 바를 가로로 생성한 파티션의 왼쪽에 세로로 그린다.
*
* @param figure
* @param g
* @param rect
* void
*/
private void drawHorizontalTitleBar(IFigure figure, Graphics g, Rectangle rect) {
g.setBackgroundColor(getBackgroundColor());
g.fillRectangle(rect);
Insets padding = getPadding();
int x = rect.x + padding.left;
int y = rect.y + padding.top + (rect.height - getTextExtents(figure).height) / 2;
int textWidth = getTextExtents(figure).width;
int freeSpace = rect.width - padding.getWidth() - textWidth;
if (getTextAlignment() == PositionConstants.CENTER)
freeSpace /= 2;
if (getTextAlignment() != PositionConstants.LEFT)
x += freeSpace;
Font f = getFont(figure);
FontData fData = f.getFontData()[0];
fData.setName(this.getFontName());
fData.setStyle(this.getTextStyle());
fData.setHeight(this.getFontSize());
g.setFont(f);
g.setForegroundColor(this.getTextColor());
g.drawString(getLabel(), x, y);
}
示例3: drawTitleBar
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* rect는 타이틀 바를 그릴 사각형이다. 여기서는 이 사각형에 타이틀 바를 그린다.
*
* @param figure
* @param g
* @param rect
* void
*/
private void drawTitleBar(IFigure figure, Graphics g, Rectangle rect) {
g.setBackgroundColor(getBackgroundColor());
g.fillRectangle(rect);
Insets padding = getPadding();
int x = rect.x + padding.left;
int y = rect.y + padding.top + (rect.height - getTextExtents(figure).height) / 2;
int textWidth = getTextExtents(figure).width;
int freeSpace = rect.width - padding.getWidth() - textWidth;
if (getTextAlignment() == PositionConstants.CENTER)
freeSpace /= 2;
if (getTextAlignment() != PositionConstants.LEFT)
x += freeSpace;
Font f = getFont(figure);
FontData fData = f.getFontData()[0];
fData.setName(this.getFontName());
fData.setStyle(this.getTextStyle());
fData.setHeight(this.getFontSize());
g.setFont(f);
g.setForegroundColor(this.getTextColor());
g.drawString(getLabel(), x, y);
}
示例4: drawMargins
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawMargins(Graphics graphics, Rectangle clippedBounds) {
if (isOpaque()) {
Rectangle t = transposer.t(clippedBounds);
graphics.setAlpha(128);
graphics.setBackgroundColor(ColorConstants.gray);
if (isHorizontal()) {
int swidth = getSize().width;
graphics.fillRectangle(0 - swidth, 0, (int) (hoffset * zoomManager.getZoom()) + swidth, t.height);
graphics.fillRectangle((int) ((hoffset + hend) * zoomManager.getZoom()), 0, swidth, t.height);
} else {
int sheight = getSize().height;
graphics.fillRectangle(0, 0 - sheight, t.width, (int) (zoomManager.getZoom() * voffset) + sheight);
graphics.fillRectangle(0, (int) ((vend + voffset) * zoomManager.getZoom()), t.width, sheight);
}
graphics.setAlpha(0);
graphics.setBackgroundColor(ColorConstants.white);
}
}
示例5: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
if(isWatched)
setBackgroundColor(watchColor);
Rectangle r = getBounds().getCopy();
if(PortAlignmentEnum.LEFT.equals(portAlignment)){
graphics.fillRectangle(getBounds().getLocation().x-20, getBounds()
.getLocation().y-1, r.width, r.height-2);
}else if(PortAlignmentEnum.RIGHT.equals(portAlignment)){
graphics.fillRectangle(getBounds().getLocation().x+20, getBounds()
.getLocation().y-1, r.width, r.height-2);
}else if(PortAlignmentEnum.BOTTOM.equals(portAlignment)){
graphics.fillRectangle(getBounds().getLocation().x-16, getBounds()
.getLocation().y+10, r.width,r.height);
}
if(isDisplayPortlabels()){
if(PortAlignmentEnum.LEFT.equals(portAlignment)){
graphics.drawText(labelOfPort,new Point(getBounds().getLocation().x+8,getBounds()
.getLocation().y-0.2));
}else if(PortAlignmentEnum.RIGHT.equals(portAlignment)){
graphics.drawText(labelOfPort,new Point(getBounds().getLocation().x,getBounds()
.getLocation().y-0.2));
}else if(PortAlignmentEnum.BOTTOM.equals(portAlignment)){
graphics.drawText(labelOfPort,new Point(getBounds().getLocation().x,getBounds()
.getLocation().y-0.2));
}
}
}
示例6: paintPagingControl
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintPagingControl(Graphics graphics) {
if (pagingControlHeight > 0){
graphics.setBackgroundColor(getPagingControlColor());
Rectangle r = getBounds().getCopy();
r.y = r.bottom() - pagingControlHeight;
r.height = pagingControlHeight;
graphics.fillRectangle(r);
graphics.setBackgroundColor(ColorConstants.white);
int diametr = Math.min(pagingControlHeight, 10);
int width = diametr*(pagesCount*2 - 1);
int x = r.getCenter().x - width / 2;
for (int i = 0; i < pagesCount; i++) {
//draw dot at the bottom
graphics.fillArc(x,
r.getCenter().y - diametr / 2, diametr, diametr,
0, 360);
x += diametr*2;
}
if (currentPage >= 0){
graphics.setBackgroundColor(ColorConstants.gray);
x = r.getCenter().x - width / 2;
x += diametr*2*currentPage;
graphics.fillArc(x,
r.getCenter().y - diametr / 2, diametr, diametr,
0, 360);
}
}
}
示例7: paintCompose
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintCompose(Graphics graphics) {
graphics.setBackgroundColor(getBarColor());
Rectangle rect = new Rectangle(2, 2, resolution.width - 4, 30);
graphics.fillRectangle(rect);
graphics.setForegroundColor(ColorConstants.white);
graphics.drawText("Compose", new Point(6, 6));
}
示例8: paintBody
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintBody(Graphics graphics) {
graphics.setBackgroundColor(background);
boolean drawCC = true;//(cc != null || bcc != null);
int fieldsCount = drawCC ? 4 : 2;
int compositeHeight = 1 + (fieldsCount * 35);
Rectangle rect = new Rectangle(2, 34, resolution.width - 4, compositeHeight);
graphics.fillRectangle(rect);
Dimension fieldSize = new Dimension(resolution.width - 16, 30);
graphics.setBackgroundColor(background2);
graphics.setForegroundColor(border);
rect = new Rectangle(new Point(8, 36), fieldSize);
//to, cc, bcc, subject
for (int i = 0; i < fieldsCount; i++) {
graphics.fillRoundRectangle(rect, radius, radius);
graphics.drawRoundRectangle(rect, radius, radius);
rect.performTranslate(0, 35);
}
//message
rect = new Rectangle(2, rect.y , resolution.width - 4, resolution.height - 160);
graphics.fillRoundRectangle(rect, radius, radius);
graphics.drawRoundRectangle(rect, radius, radius);
graphics.setForegroundColor(text);
String[] titles = getTitles(drawCC);
fieldSize.width -= 8;
for (int i = 0; i < fieldsCount; i++) {
Rectangle textRect = new Rectangle(new Point(12, 5 + (i + 1)*35), fieldSize);
Drawer.drawString(graphics, titles[i], textRect, Alignments.left, Alignments.center);
}
paintMessage(graphics, rect);
}
示例9: paindButtonsBar
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* @param graphics
*/
private void paindButtonsBar(Graphics graphics) {
int panelHeight = 42;
graphics.setBackgroundColor(defaultBarColor);
Rectangle rect = new Rectangle(2, resolution.height - 2 - panelHeight,
resolution.width - 4, panelHeight);
graphics.fillRectangle(rect);
int buttonWidth = (resolution.width - 20) / 7 ;
int space = (resolution.width - buttonWidth * 7) / 7;
graphics.setBackgroundColor(background2);
graphics.setForegroundColor(border);
rect = new Rectangle(5 + space, resolution.height - panelHeight + 2, buttonWidth*2, panelHeight - 10);
graphics.fillRoundRectangle(rect, radius, radius);
graphics.drawRoundRectangle(rect, radius, radius);
rect.translate(buttonWidth*5 + space*2, 0);
graphics.fillRoundRectangle(rect, radius, radius);
graphics.drawRoundRectangle(rect, radius, radius);
rect.translate(-buttonWidth*3 - space, 0);
rect.width = buttonWidth*3;
graphics.fillRoundRectangle(rect, radius, radius);
graphics.drawRoundRectangle(rect, radius, radius);
graphics.setForegroundColor(ColorConstants.black);
graphics.drawText("Send", new Point(22 + space, resolution.height - panelHeight + 7));
graphics.drawText("Save as Draft", new Point(12 + space*2 + buttonWidth*2, resolution.height - panelHeight + 7));
graphics.drawText("Discard", new Point(14 + space*3 + buttonWidth*5, resolution.height - panelHeight + 7));
}
示例10: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void paintFigure(final Graphics graphics) {
if (!transparent) {
graphics.fillRectangle(getClientArea());
}
super.paintFigure(graphics);
}
示例11: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void paintFigure(final Graphics graphics) {
if (!transparent)
graphics.fillRectangle(getClientArea());
super.paintFigure(graphics);
}
示例12: paint
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void paint(Graphics graphics) {
Rectangle b = getHandleBounds();
graphics.setBackgroundColor(ColorConstants.white);
graphics.fillRectangle(b.x, b.y, b.width, b.height);
super.paint(graphics);
Graphics2D g = ComponentFigure.getG2D(graphics);
if (g != null) {
twriter.painText(g, this);
Font currfont = g.getFont();
g.setFont(currfont.deriveFont(16f));
java.awt.Color currColor = g.getColor();
g.setColor(java.awt.Color.GRAY);
hintBounds = g.getFontMetrics().getStringBounds(HINT, g);
getParent().setClippingStrategy(clippingStrategy);
g.drawString(HINT, b.x, b.y - 15);
g.setColor(currColor);
g.setFont(currfont);
}
if (getParent() instanceof APageFigure) {
GridLayer grid = ((APageFigure) getParent()).getGrid();
if (grid.isVisible()) {
grid.setBounds(b);
grid.paint(graphics);
}
}
if (getBorder() != null)
getBorder().paint(this, graphics, APageFigure.PAGE_BORDER);
}
示例13: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void paintFigure(Graphics g) {
if (viewMargins) {
Rectangle clientArea = getClientArea();
clientArea.x -= dx;
clientArea.y -= dy;
Rectangle rectangle = new Rectangle(clientArea.x, clientArea.y, containerSize.width, containerSize.height);
g.setBackgroundColor(pageBackground);
g.fillRectangle(rectangle);
paintGrid(g, rectangle);
}
if (getBorder() != null)
getBorder().paint(this, g, NO_INSETS);
}
示例14: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void paintFigure(Graphics g) {
if (viewMargins) {
Rectangle clientArea = getClientArea();
clientArea.x -= dx;
clientArea.y -= dy;
int pageWidth = getSize().width;
int pageHeight = getSize().height;// + jrDesign.getTopMargin() + jrDesign.getBottomMargin();
// int leftMargin = PAGE_BORDER.left;
// int rightMargin = PAGE_BORDER.right;
// int topMargin = PAGE_BORDER.top;
// int bottomMargin = PAGE_BORDER.bottom;
Rectangle rectangle = new Rectangle(clientArea.x, clientArea.y, pageWidth, pageHeight);
g.setBackgroundColor(pageBackground);
g.fillRectangle(rectangle);
// Point topLeft = new Point(clientArea.x + leftMargin, clientArea.y);
// Point topRight = new Point(clientArea.x + pageWidth - rightMargin, clientArea.y);
// Point bottomLeft = new Point(topLeft.x, clientArea.y + pageHeight);
// Point bottomRight = new Point(topRight.x, clientArea.y + pageHeight);
// Graphics2D graphics2d = ((J2DGraphics) g).getGraphics2D();
// Stroke oldStroke = graphics2d.getStroke();
// graphics2d.setStroke(J2DUtils.getInvertedZoomedStroke(oldStroke, g.getAbsoluteScale()));
paintGrid(g, rectangle);
}
if (getBorder() != null)
getBorder().paint(this, g, NO_INSETS);
}
示例15: run
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void run() {
GC figureCanvasGC = null;
GC imageGC = null;
try {
final ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer.getRootEditPart();
rootEditPart.refresh();
final IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
final EditPart editPart = viewer.getContents();
editPart.refresh();
final ERDiagram diagram = (ERDiagram) editPart.getModel();
final Rectangle rootFigureBounds = ExportToImageAction.getBounds(diagram, rootEditPart, rootFigure.getBounds());
final Control figureCanvas = viewer.getControl();
figureCanvasGC = new GC(figureCanvas);
img = new Image(Display.getCurrent(), rootFigureBounds.width + 20, rootFigureBounds.height + 20);
imageGC = new GC(img);
imageGC.setBackground(figureCanvasGC.getBackground());
imageGC.setForeground(figureCanvasGC.getForeground());
imageGC.setFont(figureCanvasGC.getFont());
imageGC.setLineStyle(figureCanvasGC.getLineStyle());
imageGC.setLineWidth(figureCanvasGC.getLineWidth());
imageGC.setAntialias(SWT.OFF);
final Graphics imgGraphics = new SWTGraphics(imageGC);
imgGraphics.setBackgroundColor(figureCanvas.getBackground());
imgGraphics.fillRectangle(0, 0, rootFigureBounds.width + 20, rootFigureBounds.height + 20);
imgGraphics.translate(ExportToImageAction.translateX(rootFigureBounds.x),
ExportToImageAction.translateY(rootFigureBounds.y));
rootFigure.paint(imgGraphics);
} finally {
if (figureCanvasGC != null) {
figureCanvasGC.dispose();
}
if (imageGC != null) {
imageGC.dispose();
}
}
}