Examples of JsStringFunction


Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

        shapePanel
                .add(PV.Dot)
                .data(shapeLegend.entrySet())
                .top(2 + (SHAPE_SIZE / 2))
                .shape(new JsStringFunction() {
                    @Override
                    public String f(JsArgs args) {
                        Map.Entry<String, String> entry = args.getObject();
                        return entry.getKey();
                    }
                })
                .size(SHAPE_SIZE)
                .left(new JsDoubleFunction() {

                    private int currentWidth = 0;

                    @Override
                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        Map.Entry<String, String> entry = args.getObject();

                        if (_this.index() == 0) {
                            currentWidth = 0;
                        }

                        int left = currentWidth + SHAPE_SIZE;

                        currentWidth += textWidths.get(entry.getValue())
                                + SHAPE_SIZE + SHAPE_LEGEND_LABEL_SPACING;

                        return left;
                    }
                }).anchor(PVAlignment.RIGHT).add(PV.Label).font(FONT)
                .text(new JsStringFunction() {
                    @Override
                    public String f(JsArgs args) {
                        Map.Entry<String, String> entry = args.getObject();
                        return entry.getValue();
                    }
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

                .visible(new JsBooleanFunction() {
                    public boolean f(JsArgs args) {
                        double d = args.getDouble(0);
                        return d > .15;
                    }
                }).textAngle(0).text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        double d = args.getDouble(0);
                        return JsUtils.toFixed(d, 2);
                    }
                });
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

        shapePanel
                .add(PV.Dot)
                .data(shapeLegend.entrySet())
                .top(2 + (SHAPE_SIZE / 2))
                .shape(new JsStringFunction() {
                    @Override
                    public String f(JsArgs args) {
                        Map.Entry<String, String> entry = args.getObject();
                        return entry.getKey();
                    }
                })
                .size(SHAPE_SIZE)
                .left(new JsDoubleFunction() {

                    private int currentWidth = 0;

                    @Override
                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        Map.Entry<String, String> entry = args.getObject();

                        if (_this.index() == 0) {
                            currentWidth = 0;
                        }

                        int left = currentWidth + SHAPE_SIZE;

                        currentWidth += textWidths.get(entry.getValue())
                                + SHAPE_SIZE + SHAPE_LEGEND_LABEL_SPACING;

                        return left;
                    }
                }).anchor(PVAlignment.RIGHT).add(PV.Label).font(FONT)
                .text(new JsStringFunction() {
                    @Override
                    public String f(JsArgs args) {
                        Map.Entry<String, String> entry = args.getObject();
                        return entry.getValue();
                    }
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

                        }).nodes()).group(true).orient("left");

        layout.link().add(PV.Line).strokeStyle("#ccc").lineWidth(1)
                .antialias(false);

        layout.node().add(PV.Dot).fillStyle(new JsStringFunction() {
            public String f(JsArgs args) {
                PVDomNode n = args.getObject();
                return n.firstChild() != null ? "#aec7e8" : "#ff7f0e";
            }
        });
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

        vis.add(PV.Rule).data(new JsFunction<JavaScriptObject>() {
            @Override
            public JavaScriptObject f(JsArgs args) {
                return x.ticks();
            }
        }).strokeStyle(new JsStringFunction() {
            public String f(JsArgs args) {
                double d = args.getDouble(0);
                return d != 0 ? "#ccc" : "#999";
            }
        }).left(x).anchor(BOTTOM).add(PV.Label).text(x.tickFormat());

        /* Y-axis and ticks. */
        vis.add(PV.Rule).data(new JsFunction<JavaScriptObject>() {
            @Override
            public JavaScriptObject f(JsArgs args) {
                return y.ticks();
            }
        }).strokeStyle(new JsStringFunction() {
            public String f(JsArgs args) {
                double d = args.getDouble(0);
                return d != 0 ? "#ccc" : "#999";
            }
        }).top(y).anchor(LEFT).add(PV.Label).text(y.tickFormat());
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

            public double f(JsArgs args) {
                double d = args.getDouble();
                return d * h + 1;
            }
        }).left(0).right(20).lineWidth(2).strokeStyle("white").anchor(RIGHT)
                .add(PV.Label).text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        int d = args.getInt(0);
                        return d + "\u00b0";
                    }
                });

        /* Actual and forecast range. */
        record.add(PV.Bar).visible(new JsBooleanFunction() {
            public boolean f(JsArgs args) {
                WeatherRecord d = args.getObject();
                return d.hasActual();
            }
        }).bottom(new JsDoubleFunction() {
            public double f(JsArgs args) {
                WeatherRecord d = args.getObject();
                return d.actual.low * h;
            }
        }).height(new JsDoubleFunction() {
            public double f(JsArgs args) {
                WeatherRecord d = args.getObject();
                return (d.actual.high - d.actual.low) * h;
            }
        }).left(new JsDoubleFunction() {
            public double f(JsArgs args) {
                PVMark _this = args.getThis();
                return _this.index() * w + 3;
            }
        }).width(w - 8).fillStyle("black").add(PV.Bar)
                .visible(new JsBooleanFunction() {
                    public boolean f(JsArgs args) {
                        WeatherRecord d = args.getObject();
                        return d.hasForecast();
                    }
                }).bottom(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        WeatherRecord d = args.getObject();
                        return d.forecast.highMin * h;
                    }
                }).height(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        WeatherRecord d = args.getObject();
                        return (d.forecast.highMax - d.forecast.highMin) * h;
                    }
                }).add(PV.Bar).bottom(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        WeatherRecord d = args.getObject();
                        return d.forecast.lowMin * h;
                    }
                }).height(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        WeatherRecord d = args.getObject();
                        return (d.forecast.lowMax - d.forecast.lowMin) * h;
                    }
                }).add(PV.Bar).bottom(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        WeatherRecord d = args.getObject();
                        return d.forecast.lowMin * h;
                    }
                }).height(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        WeatherRecord d = args.getObject();
                        return (d.forecast.highMax - d.forecast.lowMin) * h;
                    }
                }).left(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        return _this.index() * w + 3 + Math.floor((w - 8) / 3);
                    }
                }).width(Math.ceil((w - 8) / 3));

        /* Day labels. */
        record.anchor(TOP).add(PV.Label).top(16).text(new JsStringFunction() {
            public String f(JsArgs args) {
                WeatherRecord d = args.getObject(0);
                return d.day;
            }
        });
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

                    }
                }).strokeStyle("#999");

        /* Title bar. */
        cell.add(PV.Bar).height(14).fillStyle("bisque").anchor(CENTER)
                .add(PV.Label).text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        Map.Entry<String, Map<String, List<Barley>>> site = args
                                .getObject();
                        return site.getKey();
                    }
                });

        /* A dot showing the yield. */
        PVDot dot = cell
                .add(PV.Panel)
                .data(new JsFunction<JsArrayGeneric<Entry<String, List<Barley>>>>() {
                    public JsArrayGeneric<Entry<String, List<Barley>>> f(
                            JsArgs args) {
                        Map.Entry<String, Map<String, List<Barley>>> site = args
                                .getObject();
                        return JsUtils.toJsArrayGeneric(site.getValue()
                                .entrySet());
                    }
                }).top(23).add(PV.Dot)
                .data(new JsFunction<JsArrayGeneric<Barley>>() {
                    public JsArrayGeneric<Barley> f(JsArgs args) {
                        Map.Entry<String, List<Barley>> year = args.getObject();
                        return JsUtils.toJsArrayGeneric(year.getValue());
                    }
                }).left(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        Barley d = args.getObject();
                        return x.fd(d.yield);
                    }
                }).top(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        return _this.index() * 11;
                    }
                }).size(12).lineWidth(2).strokeStyle(new JsFunction<PVColor>() {
                    public PVColor f(JsArgs args) {
                        Barley d = args.getObject();
                        return c.fcolor(d.year);
                    }
                });

        /* A label showing the variety. */
        dot.anchor(LEFT).add(PV.Label).visible(new JsBooleanFunction() {
            public boolean f(JsArgs args) {
                PVMark _this = args.getThis();
                return _this.parent().index() == 0;
            }
        }).left(-1).text(new JsStringFunction() {
            public String f(JsArgs args) {
                Barley d = args.getObject();
                return d.variety;
            }
        });

        /* X-ticks. */
        vis.add(PV.Rule).data(x.ticks(7)).left(x).bottom(-5).height(5)
                .strokeStyle("#999").anchor(BOTTOM).add(PV.Label);

        // /* A legend showing the year. */
        vis.add(PV.Dot).extend(dot).dataInt(1931, 1932)
                .left(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        PVMark _this = args.getThis();
                        return 170 + _this.index() * 40;
                    }
                }).top(-8).strokeStyle(new JsFunction<PVColor>() {
                    public PVColor f(JsArgs args) {
                        int year = args.getInt();
                        return c.fcolor(year);
                    }
                }).anchor(RIGHT).add(PV.Label).text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        int year = args.getInt();
                        return "" + year;
                    }
                });
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

        xtick.anchor(BOTTOM).add(PV.Label).visible(new JsBooleanFunction() {
            public boolean f(JsArgs args) {
                return (cell.parent().index() == traits.length - 1)
                        && (cell.index() % 2 == 0);
            }
        }).text(new JsStringFunction() {
            public String f(JsArgs args) {
                double d = args.getDouble();
                TraitPair t = args.getObject(1);
                return position.get(t.px).tickFormatDouble(d);
            };
        });

        /* Top label. */
        xtick.anchor(TOP).add(PV.Label).visible(new JsBooleanFunction() {
            public boolean f(JsArgs args) {
                return (cell.parent().index() == 0) && (cell.index() % 2 == 1);
            }
        }).text(new JsStringFunction() {
            public String f(JsArgs args) {
                double d = args.getDouble(0);
                TraitPair t = args.getObject(1);
                return position.get(t.px).tickFormatDouble(d);
            };
        });

        /* Y-axis ticks. */
        PVRule ytick = plot.add(PV.Rule)
                .data(new JsFunction<JavaScriptObject>() {
                    public JavaScriptObject f(JsArgs args) {
                        TraitPair t = args.getObject(0);
                        return position.get(t.py).ticks(5);
                    };
                }).bottom(new JsDoubleFunction() {
                    public double f(JsArgs args) {
                        double d = args.getDouble(0);
                        TraitPair t = args.getObject(1);
                        return position.get(t.py).fd(d);
                    };
                }).strokeStyle("#eee");

        /* Left label. */
        ytick.anchor(LEFT).add(PV.Label).visible(new JsBooleanFunction() {
            public boolean f(JsArgs args) {
                return (cell.index() == 0) && (cell.parent().index() % 2 == 1);
            }
        }).text(new JsStringFunction() {
            public String f(JsArgs args) {
                double d = args.getDouble(0);
                TraitPair t = args.getObject(1);
                return position.get(t.py).tickFormatDouble(d);
            };
        });

        /* Right label. */
        ytick.anchor(RIGHT).add(PV.Label).visible(new JsBooleanFunction() {
            public boolean f(JsArgs args) {
                return (cell.index() == traits.length - 1)
                        && (cell.parent().index() % 2 == 0);
            }
        }).text(new JsStringFunction() {
            public String f(JsArgs args) {
                double d = args.getDouble(0);
                TraitPair t = args.getObject(1);
                return position.get(t.py).tickFormatDouble(d);
            };
        });

        /* Frame and dot plot. */
        plot.add(PV.Dot).data(flowers).left(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Flower d = args.getObject(0);
                TraitPair t = args.getObject(1);
                return position.get(t.px).fd(d.getTraitValue(t.px));
            };
        }).bottom(new JsDoubleFunction() {
            public double f(JsArgs args) {
                Flower d = args.getObject(0);
                TraitPair t = args.getObject(1);
                return position.get(t.py).fd(d.getTraitValue(t.py));
            };
        }).size(10).strokeStyle((String) null)
                .fillStyle(new JsFunction<PVColor>() {
                    public PVColor f(JsArgs args) {
                        Flower d = args.getObject(0);
                        return color.fcolor(d.species);
                    }
                });

        /* Labels along the diagonal. */
        cell.anchor(CENTER).add(PV.Label).visible(new JsBooleanFunction() {
            public boolean f(JsArgs args) {
                TraitPair t = args.getObject(0);
                return t.px.equals(t.py);
            }
        }).font("bold 14px sans-serif").text(new JsStringFunction() {
            public String f(JsArgs args) {
                TraitPair t = args.getObject(0);
                return t.px;
            }
        });
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

            }
        });

        /* The value label. */
        bar.anchor(RIGHT).add(PV.Label).textStyle("white")
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        double d = args.getDouble(0);
                        return JsUtils.toFixed(d, 1);
                    }
                });

        /* The variable label. */
        bar.parent().anchor(LEFT).add(PV.Label).textAlign(RIGHT).textMargin(5)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        PVMark _this = args.getThis();
                        int i = _this.parent().index();
                        return "ABCDEFGHIJK".substring(i, i + 1);
                    }
                });

        /* X-axis ticks. */
        vis.add(PV.Rule).data(x.ticks(5)).left(x)
                .strokeStyle(new JsStringFunction() {
                    public String f(JsArgs args) {
                        double d = args.getDouble(0);
                        return d != 0 ? "rgba(255,255,255,.3)" : "#000";
                    }
                }).add(PV.Rule).bottom(0).height(5).strokeStyle("#000")
View Full Code Here

Examples of org.thechiselgroup.choosel.protovis.client.jsutil.JsStringFunction

                        PVDomNode d = args.getObject();
                        return d.nodeValueDouble();
                    }
                });

        pack.node().add(PV.Dot).fillStyle(new JsStringFunction() {
            public String f(JsArgs args) {
                PVDomNode d = args.getObject();
                return d.firstChild() != null ? "rgba(31, 119, 180, .25)"
                        : "#ff7f0e";
            }
        }).title(new JsStringFunction() {
            public String f(JsArgs args) {
                PVDomNode d = args.getObject();
                return d.nodeName()
                        + (d.firstChild() != null ? "" : ": "
                                + format.format(d.nodeValueDouble()));
            }
        }).lineWidth(1);

        pack.label().add(PV.Label).visible(new JsBooleanFunction() {
            public boolean f(JsArgs args) {
                PVDomNode d = args.getObject();
                return d.firstChild() == null;
            }
        }).text(new JsStringFunction() {
            public String f(JsArgs args) {
                PVDomNode d = args.getObject();
                int length = (int) Math.sqrt(d.nodeValueDouble()) / 20;
                return d.nodeName().substring(0,
                        Math.min(d.nodeName().length(), length));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.