use of java.awt.Rectangle 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.Rectangle in project WordCram by danbernier.
the class AnEngineWord method willSetItselfOnItsWord.
@Test
public void willSetItselfOnItsWord() {
Word aWord = new Word("hello", 42.0f);
EngineWord engineWord = new EngineWord(aWord, 1, 1000, new BBTreeBuilder());
// To verify that it hooked up to the Word, set EWord's shape, and get it from Word.
int anySwelling = 0;
int width = 939;
int height = 42;
engineWord.setShape(new Rectangle(0, 0, width, height), anySwelling);
double zeroDelta = 0.0;
Assert.assertEquals(width, aWord.getRenderedWidth(), zeroDelta);
Assert.assertEquals(height, aWord.getRenderedHeight(), zeroDelta);
}
use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.
the class AnimationStripPanel method getStripSize.
private Dimension getStripSize() {
Dimension ret = new Dimension(0, 0);
for (int i = 0; i < slotList.size(); ++i) {
Rectangle slotRect = slotList.get(i).getRect();
int bottom = slotRect.y + slotRect.height;
int right = slotRect.x + slotRect.width;
if (bottom > ret.height)
ret.height = bottom;
if (right > ret.width)
ret.width = right;
}
return ret;
}
use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.
the class AnimationStripPanel method addCell.
private void addCell(AnimationCell aCell) {
Point p = new Point(0, 0);
if (slotList.size() > 0) {
Rectangle lastSlotRect = slotList.get(slotList.size() - 1).getRect();
p.x = lastSlotRect.x + lastSlotRect.width;
}
Slot slot = new Slot(aCell, p, 86);
slotList.add(slot);
for (int i = 0; i < slotList.size(); ++i) slotList.get(i).setSelected(false);
slot.setSelected(true);
// stretch and update scrollbar
Dimension stripSize = getStripSize();
this.setPreferredSize(stripSize);
this.setSize(stripSize);
animation.setCurrentCellIndex(slotList.size() - 1);
if (controller != null) {
controller.setWorkingCell(aCell);
controller.stripIndexSelected(slotList.size() - 1);
}
repaint();
}
use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.
the class AnimationStripPanel method mousePressed.
public void mousePressed(MouseEvent evt) {
Point p = evt.getPoint();
controller.stripIndexSelected(-1);
boolean selectedSlot = false;
for (int i = 0; i < slotList.size(); ++i) {
Slot slot = slotList.get(i);
slot.setSelected(false);
Rectangle rect = slot.getRect();
if (MathUtil.pointRectCollide(p, rect)) {
slot.setSelected(true);
controller.stripIndexSelected(i);
//slot.setDragged(true);
controller.setWorkingCell(slot.getCell());
selectedSlot = true;
}
}
if (!selectedSlot)
controller.setWorkingCell(null);
repaint();
}
Aggregations