本文整理汇总了Java中org.eclipse.draw2d.Graphics.clipRect方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.clipRect方法的具体用法?Java Graphics.clipRect怎么用?Java Graphics.clipRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.Graphics
的用法示例。
在下文中一共展示了Graphics.clipRect方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: 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;
}
}
示例3: paintHasImage
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintHasImage(Graphics graphics) {
if (hasImage != null){
Rectangle clientArea = getClientArea();
clientArea.setLocation(getLocation());
graphics.clipRect(clientArea);
int dy = (clientArea.height - hasImageDimension.height) /2;
Rectangle dest = new Rectangle(
new Point(clientArea.right() - hasImageDimension.width - 10,
clientArea.y + dy),
hasImageDimension
);
Rectangle src = new Rectangle(0, 0,
hasImage.getImageData().width, hasImage.getImageData().height);
graphics.drawImage(hasImage, src, dest);
}
}
示例4: paintRightImage
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintRightImage(Graphics graphics) {
if (rightImage != null){
Rectangle clientArea = getClientArea();
clientArea.setLocation(getLocation());
graphics.clipRect(clientArea);
int dy = (clientArea.height - rightImageDimension.height) /2;
Rectangle dest = new Rectangle(
new Point(clientArea.right() - rightImageDimension.width - 10,
clientArea.y + dy),
rightImageDimension
);
Rectangle src = new Rectangle(0, 0,
rightImage.getImageData().width, rightImage.getImageData().height);
graphics.drawImage(rightImage, src, dest);
}
}
示例5: 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();
}
}
示例6: 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);
}
示例7: paintChildren
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Override the original paintChildren to avoid to pain elements
* that are marked as not visible inside the model
*/
protected void paintChildren(Graphics graphics) {
for (int i = 0; i < getChildren().size(); i++) {
IFigure child = (IFigure) getChildren().get(i);
if (child.isVisible() && isFigurevisible(child)) {
// determine clipping areas for child
Rectangle[] clipping = null;
if (getClippingStrategy() != null) {
clipping = getClippingStrategy().getClip(child);
} else {
// default clipping behavior is to clip at bounds
clipping = new Rectangle[] { child.getBounds() };
}
// child may now paint inside the clipping areas
for (int j = 0; j < clipping.length; j++) {
if (clipping[j].intersects(graphics.getClip(Rectangle.SINGLETON))) {
graphics.clipRect(clipping[j]);
child.paint(graphics);
graphics.restoreState();
}
}
}
}
}
示例8: 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
示例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: drawString
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
public static void drawString(Graphics graphics, String text, Rectangle parentRect,
Alignments hAlign, Alignments vAlign, int textMargin) {
if (text != null && text.length() > 0){
graphics.pushState();
Dimension textSize = FigureUtilities.getStringExtents(text, graphics.getFont());
Point textLocation = getTextLocation(parentRect,
textSize, hAlign, vAlign, textMargin);
graphics.clipRect(parentRect);
graphics.drawString(text, textLocation);
graphics.popState();
}
}
示例11: 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();
}
示例12: paintChildren
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Override the original paintChildren to avoid to pain elements
* that are marked as not visible inside the model
*/
protected void paintChildren(Graphics graphics) {
//if (!isMainEditor()) return;
for (int i = 0; i < getChildren().size(); i++) {
IFigure child = (IFigure) getChildren().get(i);
boolean modelVisible = true;
if (child instanceof FrameFigure){
ANode model = ((FrameFigure)child).getModel();
if (model != null) {
modelVisible = model.isVisible();
child.setVisible(modelVisible);
}
}
if (child.isVisible() && modelVisible && isFigurevisible(child)) {
// determine clipping areas for child
Rectangle[] clipping = null;
if (getClippingStrategy() != null) {
clipping = getClippingStrategy().getClip(child);
} else {
// default clipping behavior is to clip at bounds
clipping = new Rectangle[] { child.getBounds() };
}
// child may now paint inside the clipping areas
for (int j = 0; j < clipping.length; j++) {
if (clipping[j].intersects(graphics.getClip(Rectangle.SINGLETON))) {
graphics.clipRect(clipping[j]);
child.paint(graphics);
graphics.restoreState();
}
}
}
}
}
示例13: paintChildren
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintChildren(Graphics graphics) {
graphics.clipRect(getClientArea(new Rectangle()));
super.paintChildren(graphics);
}
示例14: paintChildren
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintChildren(Graphics graphics) {
graphics.clipRect(getWindowRect());
super.paintChildren(graphics);
}