本文整理汇总了Java中org.eclipse.draw2d.Graphics.popState方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.popState方法的具体用法?Java Graphics.popState怎么用?Java Graphics.popState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.Graphics
的用法示例。
在下文中一共展示了Graphics.popState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
graphics.pushState();
if(axis.isShowMajorGrid()){
graphics.setLineStyle(axis.isDashGridLine()? SWTConstants.LINE_DASH : SWTConstants.LINE_SOLID);
graphics.setForegroundColor(axis.getMajorGridColor());
graphics.setLineWidth(1);
for(int pos: axis.getScaleTickLabels().getTickLabelPositions()){
if(axis.isHorizontal())
graphics.drawLine(axis.getBounds().x + pos, bounds.y + bounds.height,
axis.getBounds().x + pos, bounds.y);
else
graphics.drawLine(bounds.x, axis.getBounds().y + axis.getBounds().height - pos, bounds.x + bounds.width,
axis.getBounds().y + axis.getBounds().height - pos);
}
}
graphics.popState();
}
示例2: printPages
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void printPages() {
final Graphics graphics = getFreshPrinterGraphics();
final IFigure figure = getPrintSource();
setupPrinterGraphicsFor(graphics, figure);
final Rectangle bounds = figure.getBounds();
int x = bounds.x, y = bounds.y;
final Rectangle clipRect = new Rectangle();
while (y < bounds.y + bounds.height) {
while (x < bounds.x + bounds.width) {
graphics.pushState();
getPrinter().startPage();
graphics.translate(-x, -y);
graphics.getClip(clipRect);
clipRect.setLocation(x, y);
graphics.clipRect(clipRect);
figure.paint(graphics);
getPrinter().endPage();
graphics.popState();
x += clipRect.width;
}
x = bounds.x;
y += clipRect.height;
}
}
示例3: drawShadowLayer
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawShadowLayer(Rectangle rectangle, Graphics graphics,
int offset, Color color) {
// Save the state of the graphics object
graphics.pushState();
graphics.setLineWidth(0);
graphics.setBackgroundColor(color);
Rectangle shadowLayer = new Rectangle(rectangle);
shadowLayer.x += offset;
shadowLayer.y += offset;
Dimension cornerDimensions = getCornerDimensions();
graphics.fillRoundRectangle(shadowLayer, cornerDimensions.width,
cornerDimensions.height);
// Restore the start of the graphics object
graphics.popState();
}
示例4: printPages
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void printPages() {
Graphics graphics = getFreshPrinterGraphics();
IFigure figure = getPrintSource();
setupPrinterGraphicsFor(graphics, figure);
Rectangle bounds = figure.getBounds();
int x = bounds.x, y = bounds.y;
Rectangle clipRect = new Rectangle();
while (y < bounds.y + bounds.height) {
while (x < bounds.x + bounds.width) {
graphics.pushState();
getPrinter().startPage();
graphics.translate(-x, -y);
graphics.getClip(clipRect);
clipRect.setLocation(x, y);
graphics.clipRect(clipRect);
figure.paint(graphics);
getPrinter().endPage();
graphics.popState();
x += clipRect.width;
}
x = bounds.x;
y += clipRect.height;
}
}
示例5: paintClientArea
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* No ScaledGraphics needed here, only setScale() on the passed graphics. Graphics state is preserved.
*
* @param graphics
* the graphics
* @see org.eclipse.draw2d.Figure#paintClientArea(org.eclipse.draw2d.Graphics)
*/
protected void paintClientArea(Graphics graphics) {
if (getChildren().isEmpty())
return;
if (!(graphics instanceof J2DGraphics)) {
super.paintClientArea(graphics);
} else {
double scale = getScale();
if (Double.compare(scale, 1.0) == 0) {
// Hopefully this will have the same effet
// on the inherited code!
super.paintClientArea(graphics);
} else {
boolean optimizeClip = getBorder() == null || getBorder().isOpaque();
if (!optimizeClip)
graphics.clipRect(getBounds().getCropped(getInsets()));
graphics.pushState();
graphics.scale(scale);
paintChildren(graphics);
graphics.popState();
}
}
}
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:30,代码来源:J2DScalableFreeformLayeredPane.java
示例6: paintMessage
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintMessage(Graphics graphics, Rectangle parentRect) {
String message = Utils.getString(this.message, "");
List<String> text = SWTWordWrap.wrap(message, resolution.width - 24, graphics.getFont());
if (text != null && text.size() > 0){
int oneLineHeight = getMargin()
+ FigureUtilities.getStringExtents("X", graphics.getFont()).height;
graphics.pushState();
graphics.clipRect(parentRect);
int y = parentRect.y;
for (int i = 0; y < parentRect.bottom() && i < text.size(); i++) {
Rectangle lineRect = new Rectangle(parentRect.x, y, parentRect.width,
oneLineHeight + getMargin());
Drawer.drawString(graphics, text.get(i), lineRect, Alignments.left, Alignments.top, getMargin());
y += oneLineHeight;
}
graphics.popState();
}
}
示例7: paint
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
public void paint(IFigure figure, Graphics graphics, Insets insets) {
if (!is3D()) {
return;
}
graphics.setBackgroundColor(SHADOW_COLOR);
Rectangle rec = getProportionalBounds().getTranslated(SHADOW_SIZE, SHADOW_SIZE);
graphics.pushState();
graphics.clipRect(rec);
// graphics.setClip(new Rectangle(rec.x, rec.y + rec.height -
// getShift(), rec.width, getShift()));
fillShape(graphics, rec);
graphics.popState();
// graphics.setClip(new Rectangle(rec.x + rec.width - getShift(),
// rec.y, getShift(), rec.height));
// fillShape(graphics, rec);
}
示例8: drawPolyline
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Draw polyline with the line style and line width of the trace.
*
* @param graphics
* @param pl
*/
private void drawPolyline(Graphics graphics, PointList pl) {
graphics.pushState();
graphics.setLineWidth(lineWidth);
switch(traceType) {
case SOLID_LINE:
case STEP_HORIZONTALLY:
case STEP_VERTICALLY:
graphics.setLineStyle(SWTConstants.LINE_SOLID);
graphics.drawPolyline(pl);
break;
case DASH_LINE:
graphics.setLineStyle(SWTConstants.LINE_DASH);
graphics.drawPolyline(pl);
break;
default:
break;
}
graphics.popState();
}
示例9: printPages
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void printPages() {
final Graphics graphics = getFreshPrinterGraphics();
final IFigure figure = getPrintSource();
setupPrinterGraphicsFor(graphics, figure);
final Rectangle bounds = figure.getBounds();
int x = bounds.x, y = bounds.y;
final Rectangle clipRect = new Rectangle();
while (y < bounds.y + bounds.height) {
while (x < bounds.x + bounds.width) {
graphics.pushState();
getPrinter().startPage();
graphics.translate(-x, -y);
graphics.getClip(clipRect);
clipRect.setLocation(x, y);
graphics.clipRect(clipRect);
figure.paint(graphics);
getPrinter().endPage();
graphics.popState();
x += clipRect.width;
}
x = bounds.x;
y += clipRect.height;
}
}
示例10: outlineShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void outlineShape(Graphics graphics) {
graphics.pushState();
//Outline with foreground
graphics.setForegroundColor(getBackgroundColor());
super.outlineShape(graphics);
// draw the 'H' letter
graphics.setForegroundColor(getForegroundColor());
graphics.setBackgroundColor(getBackgroundColor());
graphics.drawLine(
bounds.getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), (int) (-bounds.height * HEIGHT_RATIO)), bounds
.getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), (int) (bounds.height * HEIGHT_RATIO)));
graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * OFFSET), (int) (-bounds.height * HEIGHT_RATIO)),
bounds.getCenter().getTranslated((int) (bounds.width * OFFSET), (int) (bounds.height * HEIGHT_RATIO)));
graphics.drawLine(bounds.getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), 0), bounds.getCenter()
.getTranslated((int) (bounds.width * OFFSET), 0));
// draw the '*' character
graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * WIDTH_RATIO), (int) (-bounds.height * HEIGHT_RATIO)),
bounds.getCenter().getTranslated((int) (bounds.width * WIDTH_RATIO), (int) (-bounds.height * OFFSET)));
graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * 0.15), (int) (-bounds.height * 0.20)),
bounds.getCenter().getTranslated((int) (bounds.width * 0.35), (int) (-bounds.height * 0.10)));
graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * 0.35), (int) (-bounds.height * 0.20)),
bounds.getCenter().getTranslated((int) (bounds.width * 0.15), (int) (-bounds.height * 0.10)));
graphics.popState();
}
示例11: outlineShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* @see org.eclipse.draw2d.Shape#outlineShape(org.eclipse.draw2d.Graphics)
*/
@Override
protected void outlineShape(Graphics graphics) {
graphics.pushState();
graphics.setForegroundColor(getForegroundColor());
graphics.setBackgroundColor(getBackgroundColor());
Rectangle f = Rectangle.SINGLETON;
Rectangle r = getBounds();
f.x = r.x + getLineWidth() / 2;
f.y = r.y + getLineWidth() / 2;
f.width = r.width - getLineWidth() - 1;
f.height = r.height - getLineWidth() - 1;
PointList pl = new PointList();
pl.addPoint(f.getTop());
pl.addPoint(f.getRight());
pl.addPoint(f.getBottom());
pl.addPoint(f.getLeft());
graphics.drawPolygon(pl);
graphics.popState();
}
示例12: drawShadowLayer
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawShadowLayer(final Rectangle rectangle, final Graphics graphics, final int offset, final Color color) {
// Save the state of the graphics object
graphics.pushState();
graphics.setLineWidth(0);
graphics.setBackgroundColor(color);
final Rectangle shadowLayer = new Rectangle(rectangle);
shadowLayer.x += offset;
shadowLayer.y += offset;
final Dimension cornerDimensions = getCornerDimensions();
graphics.fillRoundRectangle(shadowLayer, cornerDimensions.width, cornerDimensions.height);
// Restore the start of the graphics object
graphics.popState();
}
示例13: paintTitle
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void paintTitle(Graphics graphics) {
if (Utils.isNotEmpty(getText())){
graphics.pushState();
Color bgColor = graphics.getBackgroundColor();
graphics.setBackgroundColor(ColorConstants.white);
int titleHeight = FigureUtilities.getStringExtents(getText(), titleFont).height;
Rectangle titleRect = getTextHolderRectangle();
Rectangle imRect = new Rectangle(titleRect.x + getMargin(),
titleRect.y + getMargin(), titleHeight, titleHeight);
graphics.fillArc(imRect, 0, 360);
graphics.setBackgroundColor(bgColor);
imRect.shrink(4, 4);
graphics.fillArc(imRect, 0, 360);
graphics.setBackgroundColor(ColorConstants.white);
graphics.fillPolygon(new int[]{imRect.x + imRect.width / 6,
imRect.y + imRect.width / 3,
imRect.x + imRect.width - imRect.width/ 6,
imRect.y + imRect.width / 3,
imRect.x + imRect.width/ 2,
imRect.y + imRect.width});
graphics.setBackgroundColor(ColorConstants.gray);
graphics.drawLine(titleRect.x + 50, titleRect.y + titleHeight + getMargin() + 1,
titleRect.right() - 50, titleRect.y + titleHeight + getMargin() + 1);
graphics.popState();
titleRect.x += titleHeight + getMargin()*2;
titleRect.width -= titleHeight + getMargin()*3;
paintString(graphics, getText(), titleRect);
}
}
示例14: paintTitaniumFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintTitaniumFigure(Graphics graphics) {
titleFont = createTitleFont();
graphics.pushState();
graphics.setFont(titleFont);
paintTitle(graphics);
graphics.popState();
paintLines(graphics, getLines(), getLinesHolderRectangle());
Rectangle expRect = getTextHolderRectangle();
if (explanation != null && explanation.length() > 0){
int titleHeight = getMargin()*2;
if (getText() != null && getText().length() > 0){
titleHeight += FigureUtilities.getStringExtents(getText(), titleFont).height;
}
expRect.height -= titleHeight;
expRect.y += titleHeight;
paintString(graphics, explanation, expRect);
}
if (okButton.getText() != null){
graphics.setFont(okButton.getFont_());
Dimension p = FigureUtilities.getStringExtents(okButton.getText(), okButton.getFont_());
p.expand(20, 4);
p.width = Math.min(p.width, expRect.width);
p.height = 40;
okButton.setBounds(new Rectangle(expRect.getBottomLeft().getTranslated(
(expRect.width - p.width) / 2, -2 - p.height), p));
okButton.paint(graphics);
}
titleFont.dispose();
}
示例15: paintClientArea
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintClientArea(Graphics graphics) {
if (getChildren().isEmpty())
return;
graphics.translate(getBounds().x + getInsets().left, getBounds().y
+ getInsets().top);
graphics.clipRect(getFullArea());
graphics.pushState();
paintChildren(graphics);
graphics.popState();
graphics.restoreState();
}