use of controlP5.Range in project TechReborn by TechReborn.
the class BuiltContainer method transferStackInSlot.
@Override
public ItemStack transferStackInSlot(final EntityPlayer player, final int index) {
ItemStack originalStack = ItemStack.EMPTY;
final Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
final ItemStack stackInSlot = slot.getStack();
originalStack = stackInSlot.copy();
boolean shifted = false;
for (final Range<Integer> range : this.playerSlotRanges) if (range.contains(index)) {
if (this.shiftToTile(stackInSlot))
shifted = true;
break;
}
if (!shifted)
for (final Range<Integer> range : this.tileSlotRanges) if (range.contains(index)) {
if (this.shiftToPlayer(stackInSlot))
shifted = true;
break;
}
slot.onSlotChange(stackInSlot, originalStack);
if (stackInSlot.getCount() <= 0)
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if (stackInSlot.getCount() == originalStack.getCount())
return ItemStack.EMPTY;
slot.onTake(player, stackInSlot);
}
return originalStack;
}
use of controlP5.Range in project libSBOLj by SynBioDex.
the class SequenceAnnotationTest method test_locationMethods.
@Test
public void test_locationMethods() throws SBOLValidationException {
Cut promoter_cut = promoter_SA.addCut("promoter_cut", 1);
assertTrue(gRNA_b_gene.getSequenceAnnotation("promoter_SA").getLocation("promoter_cut").equals(promoter_cut));
promoter_cut.unsetOrientation();
assertNull(promoter_cut.getOrientation());
Location test = promoter_cut;
assertNotNull(test.toString());
Cut terminator_cut = terminator_SA.addCut("terminator_cut", 100);
assertTrue(gRNA_b_gene.getSequenceAnnotation("terminator_SA").getLocation("terminator_cut").equals(terminator_cut));
Cut gene_cut = gene_SA.addCut("gene_cut", 50, OrientationType.INLINE);
assertTrue(gRNA_b_gene.getSequenceAnnotation("gene_SA").getLocation("gene_cut").equals(gene_cut));
gene_SA.removeLocation(gene_cut);
assertNull(gene_SA.getLocation("gene_cut"));
Range gene_range = gene_SA.addRange("gene_range", 50, 99);
assertTrue(gRNA_b_gene.getSequenceAnnotation("gene_SA").getLocation("gene_range").equals(gene_range));
gene_range.unsetOrientation();
assertNull(gene_range.getOrientation());
promoter_SA.removeLocation(promoter_cut);
assertNull(promoter_SA.getLocation(promoter_cut.getIdentity()));
GenericLocation promoter_glocation = promoter_SA.addGenericLocation("promoter_glocation");
assertTrue(gRNA_b_gene.getSequenceAnnotation("promoter_SA").getLocation("promoter_glocation").equals(promoter_glocation));
terminator_SA.removeLocation(terminator_cut);
assertNull(terminator_SA.getLocation("terminator_cut"));
GenericLocation terminator_glocation = terminator_SA.addGenericLocation("terminator_glocation", OrientationType.INLINE);
assertTrue(gRNA_b_gene.getSequenceAnnotation("terminator_SA").getLocation("terminator_glocation").equals(terminator_glocation));
}
use of controlP5.Range in project metron by apache.
the class WindowProcessorTest method testDenseWindow.
@Test
public void testDenseWindow() {
for (String text : new String[] { "from 2 hours ago to 30 minutes ago", "starting from 2 hours until 30 minutes", "starting from 2 hours ago until 30 minutes ago", "starting from 30 minutes ago until 2 hours ago", "from 30 minutes ago to 2 hours ago " }) {
Window w = WindowProcessor.process(text);
/*
A dense window starting 2 hour ago and continuing until 30 minutes ago
*/
Date now = new Date();
List<Range<Long>> intervals = w.toIntervals(now.getTime());
assertEquals(1, intervals.size());
assertTimeEquals(now.getTime() - TimeUnit.HOURS.toMillis(2), intervals.get(0).getMinimum());
assertTimeEquals(now.getTime() - TimeUnit.MINUTES.toMillis(30), intervals.get(0).getMaximum());
}
}
use of controlP5.Range in project metron by apache.
the class WindowProcessorTest method testRepeatWithConflictingExclusionInclusion.
@Test
public void testRepeatWithConflictingExclusionInclusion() {
Window w = WindowProcessor.process("30 minute window every 24 hours from 7 days ago including saturdays excluding weekends");
Date now = new Date();
// avoid DST impacts if near Midnight
now.setHours(6);
List<Range<Long>> intervals = w.toIntervals(now.getTime());
assertEquals(0, intervals.size());
}
use of controlP5.Range in project metron by apache.
the class WindowProcessorTest method testDateDaySpecifier.
@Test
public void testDateDaySpecifier() throws ParseException {
for (String text : new String[] { "30 minute window every 24 hours from 14 days ago including date:20171225:yyyyMMdd", "30 minute window every 24 hours from 14 days ago including date:2017-12-25:yyyy-MM-dd", "30 minute window every 24 hours from 14 days ago including date:2017/12/25" }) {
Window w = WindowProcessor.process(text);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
Date now = sdf.parse("2017/12/26 12:00");
List<Range<Long>> intervals = w.toIntervals(now.getTime());
assertEquals(1, intervals.size());
Date includedDate = new Date(intervals.get(0).getMinimum());
SimpleDateFormat equalityFormat = new SimpleDateFormat("yyyyMMdd");
assertEquals("20171225", equalityFormat.format(includedDate));
}
{
Window w = WindowProcessor.process("30 minute window every 24 hours from 14 days ago excluding date:2017/12/25");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
Date now = sdf.parse("2017/12/26 12:00");
List<Range<Long>> intervals = w.toIntervals(now.getTime());
assertEquals(13, intervals.size());
}
{
Window w = WindowProcessor.process("30 minute window every 24 hours from 14 days ago including date:2017/12/25, date:2017/12/24");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
Date now = sdf.parse("2017/12/26 12:00");
List<Range<Long>> intervals = w.toIntervals(now.getTime());
assertEquals(2, intervals.size());
{
Date includedDate = new Date(intervals.get(0).getMinimum());
SimpleDateFormat equalityFormat = new SimpleDateFormat("yyyyMMdd");
assertEquals("20171224", equalityFormat.format(includedDate));
}
{
Date includedDate = new Date(intervals.get(1).getMinimum());
SimpleDateFormat equalityFormat = new SimpleDateFormat("yyyyMMdd");
assertEquals("20171225", equalityFormat.format(includedDate));
}
}
}
Aggregations