RangeQueryBinding receiptsQ = new RangeQueryBinding(vt, RECEIPTS);
ListQueryBinding yearsQ = new ListQueryBinding(vt, "Year");
SearchQueryBinding searchQ = new SearchQueryBinding(vt, "Candidate");
// construct the filtering predicate
AndPredicate filter = new AndPredicate(searchQ.getPredicate());
filter.add(yearsQ.getPredicate());
filter.add(receiptsQ.getPredicate());
// set up the actions
AxisLayout xaxis = new AxisLayout(group, "State Code",
Constants.X_AXIS, VisiblePredicate.TRUE);
AxisLayout yaxis = new AxisLayout(group, RECEIPTS,
Constants.Y_AXIS, VisiblePredicate.TRUE);
//yaxis.setScale(Constants.LOG_SCALE);
yaxis.setRangeModel(receiptsQ.getModel());
receiptsQ.getNumberModel().setValueRange(0,65000000,0,65000000);
xaxis.setLayoutBounds(m_dataB);
yaxis.setLayoutBounds(m_dataB);
AxisLabelLayout ylabels = new AxisLabelLayout("ylab", yaxis, m_ylabB);
NumberFormat nf = NumberFormat.getCurrencyInstance();
nf.setMaximumFractionDigits(0);
ylabels.setNumberFormat(nf);
AxisLabelLayout xlabels = new AxisLabelLayout("xlab", xaxis, m_xlabB, 15);
vis.putAction("xlabels", xlabels);
// dems = blue, reps = red, other = gray
int[] palette = new int[] {
ColorLib.rgb(150,150,255), ColorLib.rgb(255,150,150),
ColorLib.rgb(180,180,180)
};
DataColorAction color = new DataColorAction(group, "Party",
Constants.ORDINAL, VisualItem.STROKECOLOR, palette);
int[] shapes = new int[]
{ Constants.SHAPE_RECTANGLE, Constants.SHAPE_DIAMOND };
DataShapeAction shape = new DataShapeAction(group, "Senate", shapes);
Counter cntr = new Counter(group);
ActionList draw = new ActionList();
draw.add(cntr);
draw.add(color);
draw.add(shape);
draw.add(xaxis);
draw.add(yaxis);
draw.add(ylabels);
draw.add(new ColorAction(group, VisualItem.FILLCOLOR, 0));
draw.add(new RepaintAction());
vis.putAction("draw", draw);
ActionList update = new ActionList();
update.add(new VisibilityFilter(group, filter));
update.add(cntr);
update.add(xaxis);
update.add(yaxis);
update.add(ylabels);
update.add(new RepaintAction());
vis.putAction("update", update);
UpdateListener lstnr = new UpdateListener() {
public void update(Object src) {
vis.run("update");
}
};
filter.addExpressionListener(lstnr);
// --------------------------------------------------------------------
// STEP 4: set up a display and ui components to show the visualization
m_display = new Display(vis);