use of controlP5.Range in project sirix by sirixdb.
the class AbstractSunburstControl method controlEvent.
/**
* Called on every change of the GUI.
*
* @param paramControlEvent
* the {@link ControlEvent}
*/
@Override
public void controlEvent(final ControlEvent paramControlEvent) {
assert paramControlEvent != null;
if (paramControlEvent.isController()) {
if (paramControlEvent.getController().getId() == 50) {
mModel.evaluateXPath(paramControlEvent.getController().getStringValue());
} else {
if (paramControlEvent.getController() instanceof Toggle) {
final Toggle toggle = (Toggle) paramControlEvent.getController();
switch(paramControlEvent.getController().getId()) {
case 0:
mGUI.setShowArcs(toggle.getState());
break;
case 1:
mGUI.setShowLines(toggle.getState());
break;
case 2:
mGUI.setUseBezierLine(toggle.getState());
break;
}
} else if (paramControlEvent.getController() instanceof Slider) {
switch(paramControlEvent.getController().getId()) {
case 0:
mGUI.setInnerNodeArcScale(paramControlEvent.getController().getValue());
break;
case 1:
mGUI.setLeafArcScale(paramControlEvent.getController().getValue());
break;
case 2:
mGUI.setModificationWeight(paramControlEvent.getController().getValue());
break;
case 3:
mGUI.setDotSize(paramControlEvent.getController().getValue());
break;
case 4:
mGUI.setDotBrightness(paramControlEvent.getController().getValue());
break;
case 5:
mGUI.setBackgroundBrightness(paramControlEvent.getController().getValue());
break;
}
} else if (paramControlEvent.getController() instanceof Range) {
final float[] f = paramControlEvent.getController().getArrayValue();
switch(paramControlEvent.getController().getId()) {
case 0:
mGUI.setHueStart(f[0]);
mGUI.setHueEnd(f[1]);
break;
case 1:
mGUI.setSaturationStart(f[0]);
mGUI.setSaturationEnd(f[1]);
break;
case 2:
mGUI.setBrightnessStart(f[0]);
mGUI.setBrightnessEnd(f[1]);
break;
case 3:
mGUI.setInnerNodeBrightnessStart(f[0]);
mGUI.setInnerNodeBrightnessEnd(f[1]);
break;
case 4:
mGUI.setInnerNodeStrokeBrightnessStart(f[0]);
mGUI.setInnerNodeStrokeBrightnessEnd(f[1]);
break;
case 5:
mGUI.setStrokeWeightStart(f[0]);
mGUI.setStrokeWeightEnd(f[1]);
break;
}
}
mGUI.update(EResetZoomer.YES);
}
}
}
use of controlP5.Range in project sirix by sirixdb.
the class AbstractSunburstGUI method setupGUI.
/**
* Initial setup of the GUI.
*/
private void setupGUI() {
mParent.textFont(mFont);
mParent.smooth();
mParent.background(255f);
final int activeColor = mParent.color(0, 130, 164);
mControlP5.setColorActive(activeColor);
mControlP5.setColorBackground(mParent.color(170));
mControlP5.setColorForeground(mParent.color(50));
mControlP5.setColorLabel(mParent.color(50));
mControlP5.setColorValue(mParent.color(255));
final int len = 300;
final Range hueRange = mControlP5.addRange("leaf node hue range", 0, 360, getHueStart(), getHueEnd(), LEFT, TOP + mPosY + 0, len, 15);
mRanges.add(hueRange);
final Range saturationRange = mControlP5.addRange("leaf node saturation range", 0, 100, getSaturationStart(), getSaturationEnd(), LEFT, TOP + mPosY + 20, len, 15);
mRanges.add(saturationRange);
final Range brightnessRange = mControlP5.addRange("leaf node brightness range", 0, 100, getBrightnessStart(), getBrightnessEnd(), LEFT, TOP + mPosY + 40, len, 15);
mRanges.add(brightnessRange);
mPosY += 70;
final Range innerNodebrightnessRange = mControlP5.addRange("inner node brightness range", 0, 100, getInnerNodeBrightnessStart(), getInnerNodeBrightnessEnd(), LEFT, TOP + mPosY + 0, len, 15);
mRanges.add(innerNodebrightnessRange);
final Range innerNodeStrokeBrightnessRange = mControlP5.addRange("inner node stroke brightness range", 0, 100, getInnerNodeStrokeBrightnessStart(), getInnerNodeStrokeBrightnessEnd(), LEFT, TOP + mPosY + 20, len, 15);
mRanges.add(innerNodeStrokeBrightnessRange);
mPosY += 50;
// name, minimum, maximum, default value (float), x, y, width, height
final Slider innerNodeArcScale = mControlP5.addSlider("setInnerNodeArcScale", 0, 1, getInnerNodeArcScale(), LEFT, TOP + mPosY + 0, len, 15);
innerNodeArcScale.setCaptionLabel("innerNodeArcScale");
mSliders.add(innerNodeArcScale);
final Slider leafNodeArcScale = mControlP5.addSlider("setLeafArcScale", 0, 1, getLeafArcScale(), LEFT, TOP + mPosY + 20, len, 15);
leafNodeArcScale.setCaptionLabel("leafNodeArcScale");
mSliders.add(leafNodeArcScale);
mPosY += 50;
final Slider modWeight = mControlP5.addSlider("setModificationWeight", 0, 1, getModificationWeight(), LEFT, TOP + mPosY + 0, len, 15);
modWeight.setCaptionLabel("modification weight");
mSliders.add(modWeight);
mPosY += 50;
final Range strokeWeight = mControlP5.addRange("stroke weight range", 0, 10, getStrokeWeightStart(), getStrokeWeightEnd(), LEFT, TOP + mPosY + 0, len, 15);
mRanges.add(strokeWeight);
mPosY += 30;
final Slider dotSize = mControlP5.addSlider("setDotSize", 0, 10, mDotSize, LEFT, TOP + mPosY + 0, len, 15);
dotSize.setCaptionLabel("dot size");
mSliders.add(dotSize);
final Slider dotBrightness = mControlP5.addSlider("setDotBrightness", 0, 100, mDotBrightness, LEFT, TOP + mPosY + 20, len, 15);
dotBrightness.setCaptionLabel("dot brightness");
mSliders.add(dotBrightness);
mPosY += 50;
final Slider backgroundBrightness = mControlP5.addSlider("setBackgroundBrightness", 0, 100, getBackgroundBrightness(), LEFT, TOP + mPosY + 0, len, 15);
backgroundBrightness.setCaptionLabel("background brightness");
mSliders.add(backgroundBrightness);
mPosY += 50;
final Toggle showArcs = mControlP5.addToggle("isShowArcs", isShowArcs(), LEFT + 0, TOP + mPosY, 15, 15);
showArcs.setCaptionLabel("show arcs");
mToggles.add(showArcs);
final Toggle showLines = mControlP5.addToggle("isShowLines", isShowLines(), LEFT + 0, TOP + mPosY + 20, 15, 15);
showLines.setCaptionLabel("show lines");
mToggles.add(showLines);
final Toggle useBezier = mControlP5.addToggle("isUseBezierLine", isUseBezierLine(), LEFT + 0, TOP + mPosY + 40, 15, 15);
useBezier.setCaptionLabel("Bezier / Line");
mToggles.add(useBezier);
setup();
style();
}
use of controlP5.Range in project metron by apache.
the class WindowProcessorTest method testRepeatWithWeekdayExclusion.
@Test
public void testRepeatWithWeekdayExclusion() throws ParseException {
Window w = WindowProcessor.process("30 minute window every 24 hours from 7 days ago excluding weekdays");
Date now = new Date();
// avoid DST impacts if near Midnight
now.setHours(6);
List<Range<Long>> intervals = w.toIntervals(now.getTime());
assertEquals(2, intervals.size());
}
use of controlP5.Range in project metron by apache.
the class WindowProcessorTest method testSparse.
@Test
public void testSparse() {
for (String text : new String[] { "30 minute window every 1 hour from 2 hours ago to 30 minutes ago", "30 minute window every 1 hour starting from 2 hours ago to 30 minutes ago", "30 minute window every 1 hour starting from 2 hours ago until 30 minutes ago", "30 minute window for every 1 hour starting from 2 hours ago until 30 minutes ago" }) {
Window w = WindowProcessor.process(text);
/*
A window size of 30 minutes
Starting 2 hour ago and continuing until 30 minutes ago
window 1: ( now - 2 hour, now - 2 hour + 30 minutes)
window 2: (now - 1 hour, now - 1 hour + 30 minutes)
*/
Date now = new Date();
List<Range<Long>> intervals = w.toIntervals(now.getTime());
assertEquals(2, intervals.size());
assertEquals(now.getTime() - TimeUnit.HOURS.toMillis(2), intervals.get(0).getMinimum());
assertEquals(now.getTime() - TimeUnit.HOURS.toMillis(2) + TimeUnit.MINUTES.toMillis(30), intervals.get(0).getMaximum());
assertEquals(now.getTime() - TimeUnit.HOURS.toMillis(1), intervals.get(1).getMinimum());
assertEquals(now.getTime() - TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(30), intervals.get(1).getMaximum());
}
}
use of controlP5.Range in project metron by apache.
the class WindowProcessorTest method testBaseCase.
@Test
public void testBaseCase() {
for (String text : new String[] { "1 hour", "1 hour(s)", "1 hours" }) {
Window w = WindowProcessor.process(text);
Date now = new Date();
List<Range<Long>> intervals = w.toIntervals(now.getTime());
assertEquals(1, intervals.size());
assertEquals(now.getTime(), (long) intervals.get(0).getMaximum());
assertEquals(now.getTime() - TimeUnit.HOURS.toMillis(1), (long) intervals.get(0).getMinimum());
}
}
Aggregations