use of java.awt.Shape in project WordCram by danbernier.
the class AWordCramEngine method willSkipWordsWhoseShapesAreTooSmallEvenWhenMinShapeSizeIsZero.
@Test
public void willSkipWordsWhoseShapesAreTooSmallEvenWhenMinShapeSizeIsZero() {
Word big = new Word("big", 10);
Word small = new Word("small", 1);
Shape bigShape = new Rectangle(0, 0, 20, 20);
Shape smallShape = new Rectangle(0, 0, 0, 1);
renderOptions.minShapeSize = 0;
when(shaper.getShapeFor(eq(big.word), any(PFont.class), anyFloat(), anyFloat())).thenReturn(bigShape);
when(shaper.getShapeFor(eq(small.word), any(PFont.class), anyFloat(), anyFloat())).thenReturn(smallShape);
WordCramEngine engine = getEngine(big, small);
Word[] skippedWords = engine.getSkippedWords();
Assert.assertEquals(1, skippedWords.length);
Assert.assertSame(small, skippedWords[0]);
Assert.assertEquals(WordSkipReason.SHAPE_WAS_TOO_SMALL, small.wasSkippedBecause());
Assert.assertNull(big.wasSkippedBecause());
}
use of java.awt.Shape in project WordCram by danbernier.
the class PlacerHeatMap method draw.
public void draw(PApplet sketch) {
RectStack rectStack = new RectStack();
for (int i = 0; i < words.length; i++) {
Word word = words[i];
PFont wordFont = word.getFont(fonter);
float wordSize = word.getSize(sizer, i, words.length);
float wordAngle = word.getAngle(angler);
Shape shape = shaper.getShapeFor(word.word, wordFont, wordSize, wordAngle);
Rectangle2D rect = shape.getBounds2D();
//return r.getHeight() < minShapeSize || r.getWidth() < minShapeSize;
int wordImageWidth = (int) rect.getWidth();
int wordImageHeight = (int) rect.getHeight();
PVector desiredLocation = word.getTargetPlace(placer, i, words.length, wordImageWidth, wordImageHeight, sketch.width, sketch.height);
//sketch.rect(desiredLocation.x, desiredLocation.y, wordImageWidth, wordImageHeight);
rectStack.add((int) desiredLocation.x, (int) desiredLocation.y, wordImageWidth, wordImageHeight);
}
RectGrid grid = new RectGrid(rectStack);
grid.draw(sketch);
}
use of java.awt.Shape in project WordCram by danbernier.
the class AWordCramEngine method willSkipWordsWhoseShapesAreTooSmall.
@Test
public void willSkipWordsWhoseShapesAreTooSmall() {
Word big = new Word("big", 10);
Word small = new Word("small", 1);
Shape bigShape = new Rectangle(0, 0, 20, 20);
Shape smallShape = new Rectangle(0, 0, 1, 1);
when(shaper.getShapeFor(eq(big.word), any(PFont.class), anyFloat(), anyFloat())).thenReturn(bigShape);
when(shaper.getShapeFor(eq(small.word), any(PFont.class), anyFloat(), anyFloat())).thenReturn(smallShape);
WordCramEngine engine = getEngine(big, small);
Word[] skippedWords = engine.getSkippedWords();
Assert.assertEquals(1, skippedWords.length);
Assert.assertSame(small, skippedWords[0]);
Assert.assertEquals(WordSkipReason.SHAPE_WAS_TOO_SMALL, small.wasSkippedBecause());
Assert.assertNull(big.wasSkippedBecause());
}
use of java.awt.Shape in project android_frameworks_base by ParanoidAndroid.
the class GcSnapshot method doRestore.
private GcSnapshot doRestore() {
if (mPrevious != null) {
if (mLocalLayer != null) {
// prepare to blit the layers in which we have draw, in the layer beneath
// them, starting with the top one (which is the current local layer).
int i = mLayers.size() - 1;
int flags;
do {
Layer dstLayer = mLayers.get(i - 1);
restoreLayer(dstLayer);
flags = dstLayer.getFlags();
i--;
} while (i > 0 && (flags & Canvas.CLIP_TO_LAYER_SAVE_FLAG) == 0);
}
// didn't save the matrix? set the current matrix on the previous snapshot
if ((mFlags & Canvas.MATRIX_SAVE_FLAG) == 0) {
AffineTransform mtx = getTransform();
for (Layer layer : mPrevious.mLayers) {
layer.getGraphics().setTransform(mtx);
}
}
// didn't save the clip? set the current clip on the previous snapshot
if ((mFlags & Canvas.CLIP_SAVE_FLAG) == 0) {
Shape clip = getClip();
for (Layer layer : mPrevious.mLayers) {
layer.setClip(clip);
}
}
}
for (Layer layer : mLayers) {
layer.getGraphics().dispose();
}
return mPrevious;
}
use of java.awt.Shape in project LuaViewSDK by alibaba.
the class EclipseTabbedPaneUI method paintTabBorder.
@Override
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) {
if (tabPlacement == BOTTOM) {
g.setColor(LINE_COLOR);
g.drawLine(x, y + h - 1, x + w, y + h - 1);
}
if (tabPlacement == TOP && isSelected) {
g.setColor(LINE_COLOR);
Shape shape = g.getClip();
g.setClip(x, y, w + 2, h);
g.drawRoundRect(x, y, w, h + R + R, R, R);
g.setClip(shape);
}
}
Aggregations