├── .gitignore ├── LICENSE ├── README.md ├── javafx-d3-demo ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.jdt.ui.prefs │ └── org.eclipse.m2e.core.prefs ├── pom.xml └── src │ ├── main │ ├── .gitignore │ ├── java │ │ └── org │ │ │ └── treez │ │ │ └── javafxd3 │ │ │ ├── d3 │ │ │ ├── JavaFxD3DemoSuite.java │ │ │ ├── JavaFxD3SingleDemo.java │ │ │ ├── demo │ │ │ │ ├── AbstractDemoCase.java │ │ │ │ ├── CaliforniaJson.java │ │ │ │ ├── Data.java │ │ │ │ ├── DataLoader.java │ │ │ │ ├── DemoCase.java │ │ │ │ ├── DemoFactory.java │ │ │ │ ├── DivElementFactory.java │ │ │ │ ├── InputElementFactory.java │ │ │ │ ├── Margin.java │ │ │ │ ├── SvgTextElementFactory.java │ │ │ │ ├── TextResource.java │ │ │ │ └── firebug_lite_test.html │ │ │ └── democases │ │ │ │ ├── .gitignore │ │ │ │ ├── arcTween │ │ │ │ ├── ArcTween.java │ │ │ │ ├── ArcTweenDataFunction.java │ │ │ │ ├── ArcTweenFunction.java │ │ │ │ └── ArcTweenInterpolator.java │ │ │ │ ├── axis │ │ │ │ ├── AxisComponent.css │ │ │ │ ├── AxisComponent.java │ │ │ │ ├── ClickDataFunction.java │ │ │ │ ├── DataDsvCallback.java │ │ │ │ ├── DataDsvObjectAccessor.java │ │ │ │ └── DsvData.java │ │ │ │ ├── barchart │ │ │ │ ├── BarChart.css │ │ │ │ ├── BarChart.java │ │ │ │ ├── BarChartCallback.java │ │ │ │ ├── BarChartData.java │ │ │ │ └── BarChartObjectAccessor.java │ │ │ │ ├── behaviors │ │ │ │ ├── DragFunction.java │ │ │ │ ├── DragMultiples.java │ │ │ │ ├── ZoomDemo.css │ │ │ │ └── ZoomDemo.java │ │ │ │ ├── chorddiagram │ │ │ │ ├── ChordDiagram.css │ │ │ │ ├── ChordDiagram.java │ │ │ │ └── GroupTick.java │ │ │ │ ├── focus │ │ │ │ ├── FocusAndContext.css │ │ │ │ ├── FocusAndContext.java │ │ │ │ └── FocusAndContextData.java │ │ │ │ ├── functionplotter │ │ │ │ └── FunctionPlotDemo.java │ │ │ │ ├── geom │ │ │ │ ├── hull │ │ │ │ │ ├── HullCoords.java │ │ │ │ │ ├── HullDataFunction.java │ │ │ │ │ ├── HullDemo.css │ │ │ │ │ ├── HullDemo.java │ │ │ │ │ ├── HullMouseClickDataFunction.java │ │ │ │ │ ├── HullMouseMoveDataFunction.java │ │ │ │ │ └── HullTransformDataFunction.java │ │ │ │ ├── mitchell │ │ │ │ │ ├── Circle.java │ │ │ │ │ ├── CircleGenerator.java │ │ │ │ │ ├── MitchellBestCandidate.java │ │ │ │ │ ├── MitchellCircleGenerator.java │ │ │ │ │ ├── MitchellTimerFunction.java │ │ │ │ │ └── MitchellVisitCallback.java │ │ │ │ └── voronoi │ │ │ │ │ ├── VoronoiTessellationDemo.css │ │ │ │ │ └── VoronoiTessellationDemo.java │ │ │ │ ├── helloworld │ │ │ │ └── HelloWorldDemo.java │ │ │ │ ├── layout │ │ │ │ ├── ClusterDendogram.css │ │ │ │ └── ClusterDendogram.java │ │ │ │ ├── lorenz │ │ │ │ ├── LorenzSystem.java │ │ │ │ └── LorenzTimerFunction.java │ │ │ │ ├── svg │ │ │ │ ├── brush │ │ │ │ │ ├── ordinal │ │ │ │ │ │ ├── OrdinalBrushingDemo.css │ │ │ │ │ │ └── OrdinalBrushingDemo.java │ │ │ │ │ ├── scatter │ │ │ │ │ │ ├── BrushEndFunction.java │ │ │ │ │ │ ├── BrushMoveFunction.java │ │ │ │ │ │ ├── BrushStartFunction.java │ │ │ │ │ │ ├── Point.java │ │ │ │ │ │ ├── ScatterPlotMatrixDemo.css │ │ │ │ │ │ └── ScatterPlotMatrixDemo.java │ │ │ │ │ ├── slider │ │ │ │ │ │ ├── BrushAsSliderDemo.css │ │ │ │ │ │ └── BrushAsSliderDemo.java │ │ │ │ │ └── transitions │ │ │ │ │ │ ├── BrushTransitionsDemo.css │ │ │ │ │ │ ├── BrushTransitionsDemo.java │ │ │ │ │ │ └── BrushTransitionsDemoCallback.java │ │ │ │ ├── line │ │ │ │ │ ├── CustomCoords.java │ │ │ │ │ ├── DefinedDataFunction.java │ │ │ │ │ ├── LineDemo.css │ │ │ │ │ └── LineDemo.java │ │ │ │ ├── symbol │ │ │ │ │ ├── SymbolDemo.css │ │ │ │ │ └── SymbolDemo.java │ │ │ │ └── text │ │ │ │ │ └── TextDemo.java │ │ │ │ ├── update │ │ │ │ ├── GeneralUpdatePattern1.css │ │ │ │ ├── GeneralUpdatePattern1.java │ │ │ │ ├── GeneralUpdatePattern2.css │ │ │ │ ├── GeneralUpdatePattern2.java │ │ │ │ ├── GeneralUpdatePattern3.css │ │ │ │ └── GeneralUpdatePattern3.java │ │ │ │ └── xy │ │ │ │ ├── XAxisDataFunction.java │ │ │ │ ├── Xy.css │ │ │ │ ├── XyDemo.java │ │ │ │ └── YAxisDataFunction.java │ │ │ ├── javafx │ │ │ └── FunctionPlotterDemo.java │ │ │ └── plotly │ │ │ ├── PlotlyBarDemo.java │ │ │ ├── PlotlyContourDemo.java │ │ │ ├── PlotlyPieDemo.java │ │ │ └── PlotlyScatterDemo.java │ └── resources │ │ ├── .gitignore │ │ ├── demo-data │ │ ├── data.tsv │ │ ├── flare.json │ │ ├── flowers.csv │ │ ├── readme.csv │ │ └── sp500.csv │ │ ├── readme.csv │ │ └── test-data │ │ ├── test.csv │ │ └── test.tsv │ └── test │ ├── java │ └── org │ │ └── treez │ │ └── javafxd3 │ │ └── d3 │ │ ├── AbstractTestCase.java │ │ ├── D3Test.java │ │ ├── arrays │ │ ├── ArrayTest.java │ │ └── Callbacks.java │ │ ├── behaviors │ │ └── ZoomTest.java │ │ ├── color │ │ ├── HslColorTest.java │ │ └── RgbColorTest.java │ │ ├── core │ │ ├── FormatTest.java │ │ ├── RandomTest.java │ │ ├── TransformTest.java │ │ └── ValueTest.java │ │ ├── dsv │ │ ├── CsvTest.java │ │ ├── TsvTest.java │ │ └── person │ │ │ ├── Person.java │ │ │ ├── PersonAccessor.java │ │ │ ├── PersonArrayAccessor.java │ │ │ ├── PersonCallback.java │ │ │ └── PersonRowCallback.java │ │ ├── functions │ │ └── DataFunctionTest.java │ │ ├── scales │ │ ├── IdentityScaleTest.java │ │ ├── LinearScaleTest.java │ │ ├── LogScaleTest.java │ │ ├── LogScaleTestDataFunction.java │ │ ├── OrdinalScaleTest.java │ │ ├── PowScaleTest.java │ │ ├── QuantileScaleTest.java │ │ ├── QuantizeScaleTest.java │ │ ├── ThresholdScaleTest.java │ │ └── TimeScaleTest.java │ │ ├── selection │ │ ├── AbstractSelectionTest.java │ │ ├── AssertOneChildDataFunction.java │ │ ├── GetSpanDataFunction.java │ │ ├── SelectionAttrTest.java │ │ ├── SelectionClassedTest.java │ │ ├── SelectionContentsTest.java │ │ ├── SelectionControlsTest.java │ │ ├── SelectionData2Test.java │ │ ├── SelectionDataTest.java │ │ ├── SelectionHtmlTest.java │ │ ├── SelectionPropertyTest.java │ │ ├── SelectionStyleTest.java │ │ ├── SelectionTextTest.java │ │ ├── SubselectionsTest.java │ │ ├── comparator │ │ │ └── ValueComparator.java │ │ ├── datafunction │ │ │ ├── AssertCounterDataFunction.java │ │ │ ├── AssertNullStringDataFunction.java │ │ │ ├── AssertOddEvenDataFunction.java │ │ │ ├── AssertStringDataFunction.java │ │ │ ├── IntegerArrayDataFunction.java │ │ │ ├── ObjectArrayDataFunction.java │ │ │ ├── OddEvenDataFunction.java │ │ │ ├── OddEvenElementDataFunction.java │ │ │ ├── PrefixPlusIndexDataFunction.java │ │ │ ├── StringBuilderFunction.java │ │ │ └── StringDataFunction.java │ │ └── keyfunction │ │ │ ├── IntegerKeyFunction.java │ │ │ └── SelectionData2KeyFunction.java │ │ ├── svg │ │ ├── AreaTest.java │ │ ├── AxisTest.java │ │ ├── ChordDef.java │ │ ├── ChordTest.java │ │ ├── LineTest.java │ │ ├── SymbolTest.java │ │ └── datafunction │ │ │ ├── ChordEndAngleDataFunction.java │ │ │ ├── ChordRadiusDataFunction.java │ │ │ ├── ChordSourceDataFunction.java │ │ │ ├── ChordStartAngleDataFunction.java │ │ │ ├── ChordTargetDataFunction.java │ │ │ ├── IndexDataFunction.java │ │ │ ├── IndexFactorDataFunction.java │ │ │ ├── IndexSwitchDataFunction.java │ │ │ ├── TickTestDataFunction.java │ │ │ ├── XCaptureDataFunction.java │ │ │ ├── XDataFunction.java │ │ │ ├── YCaptureDataFunction.java │ │ │ ├── YCoordsCounterDataFunction.java │ │ │ └── YDataFunction.java │ │ ├── time │ │ ├── JsDateTest.java │ │ ├── TestTimeIntervals.java │ │ └── TimeFormatTest.java │ │ ├── transition │ │ ├── EasingTest.java │ │ ├── InterpolatorsTest.java │ │ ├── TransitionTest.java │ │ └── function │ │ │ ├── CustomEasingFunction.java │ │ │ ├── InterpolatorTweenFunction.java │ │ │ └── TestCallableInterpolator.java │ │ └── wrapper │ │ └── JavaScriptObjectTest.java │ └── resources │ └── javafxd3.png └── javafx-d3 ├── .classpath ├── .gitignore ├── .project ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.jdt.core.prefs ├── org.eclipse.jdt.ui.prefs ├── org.eclipse.m2e.core.prefs └── org.moreunit.prefs ├── META-INF ├── MANIFEST.MF └── log4j.properties ├── build.properties ├── main ├── java │ └── org │ │ └── treez │ │ └── javafxd3 │ │ ├── d3 │ │ ├── D3.java │ │ ├── arrays │ │ │ ├── Array.java │ │ │ ├── ArrayUtils.java │ │ │ ├── Arrays.java │ │ │ └── foreach │ │ │ │ ├── CompleteForEachCallbackWrapper.java │ │ │ │ ├── ForEachCallback.java │ │ │ │ ├── ForEachCallbackWrapper.java │ │ │ │ ├── ForEachObjectDelegate.java │ │ │ │ ├── ForEachObjectDelegateWrapper.java │ │ │ │ └── NumericForEachCallback.java │ │ ├── behaviour │ │ │ ├── Behavior.java │ │ │ ├── Drag.java │ │ │ └── Zoom.java │ │ ├── color │ │ │ ├── Color.java │ │ │ ├── Colors.java │ │ │ ├── HSLColor.java │ │ │ └── RGBColor.java │ │ ├── coords │ │ │ └── Coords.java │ │ ├── core │ │ │ ├── ConversionUtil.java │ │ │ ├── EnteringSelection.java │ │ │ ├── Formatter.java │ │ │ ├── JsEngine.java │ │ │ ├── JsObject.java │ │ │ ├── Nest.java │ │ │ ├── Prefix.java │ │ │ ├── Random.java │ │ │ ├── Selection.java │ │ │ ├── Transform.java │ │ │ ├── Transition.java │ │ │ ├── UpdateSelection.java │ │ │ └── Value.java │ │ ├── dsv │ │ │ ├── Dsv.java │ │ │ ├── DsvArrayAccessor.java │ │ │ ├── DsvCallback.java │ │ │ ├── DsvObjectAccessor.java │ │ │ └── DsvRow.java │ │ ├── ease │ │ │ ├── Easing.java │ │ │ ├── EasingFunction.java │ │ │ ├── JavascriptEasingFunction.java │ │ │ └── Mode.java │ │ ├── event │ │ │ ├── D3Event.java │ │ │ └── Event.java │ │ ├── functions │ │ │ ├── DataFunction.java │ │ │ ├── DragFunction.java │ │ │ ├── JsFunction.java │ │ │ ├── KeyFunction.java │ │ │ ├── MouseClickFunction.java │ │ │ ├── ObjectAccessor.java │ │ │ ├── TimerFunction.java │ │ │ ├── accessor │ │ │ │ └── DsvObjectAccessorWrapper.java │ │ │ ├── callback │ │ │ │ ├── DsvCallbackWrapper.java │ │ │ │ └── PlainCallback.java │ │ │ ├── data │ │ │ │ ├── AppendDataFunction.java │ │ │ │ ├── ColorScaleLevelDataFunction.java │ │ │ │ ├── ConstantDataFunction.java │ │ │ │ ├── CountDataFunction.java │ │ │ │ ├── DelegatingDataFunction.java │ │ │ │ ├── EvenIndexDataFunction.java │ │ │ │ ├── PropertyValueDataFunction.java │ │ │ │ ├── array │ │ │ │ │ ├── FirstDataFunction.java │ │ │ │ │ └── SecondDataFunction.java │ │ │ │ ├── attribute │ │ │ │ │ ├── AttributeDoubleDataFunction.java │ │ │ │ │ └── AttributeStringDataFunction.java │ │ │ │ ├── axis │ │ │ │ │ ├── AxisScaleFirstDataFunction.java │ │ │ │ │ ├── AxisScaleInversedFirstDataFunction.java │ │ │ │ │ ├── AxisScaleInversedSecondDataFunction.java │ │ │ │ │ ├── AxisScaleInversedSizeDataFunction.java │ │ │ │ │ ├── AxisScaleInversedThirdDataFunction.java │ │ │ │ │ ├── AxisScaleInversedValueDataFunction.java │ │ │ │ │ ├── AxisScaleKeyDataFunction.java │ │ │ │ │ ├── AxisScaleSecondDataFunction.java │ │ │ │ │ ├── AxisScaleSizeDataFunction.java │ │ │ │ │ ├── AxisScaleThirdDatumAsSizeFunction.java │ │ │ │ │ ├── AxisScaleValueDataFunction.java │ │ │ │ │ └── AxisTransformPointDataFunction.java │ │ │ │ └── wrapper │ │ │ │ │ ├── CompleteDataFunctionWrapper.java │ │ │ │ │ ├── ContextDataFunctionWrapper.java │ │ │ │ │ ├── DataFunctionWrapper.java │ │ │ │ │ ├── IndexDataFunctionWrapper.java │ │ │ │ │ └── PlainDataFunction.java │ │ │ └── key │ │ │ │ ├── CompleteKeyFunctionWrapper.java │ │ │ │ ├── IndexKeyFunctionWrapper.java │ │ │ │ └── KeyFunctionWrapper.java │ │ ├── geo │ │ │ ├── ConicProjection.java │ │ │ ├── Geography.java │ │ │ └── Projection.java │ │ ├── geom │ │ │ ├── Geometry.java │ │ │ ├── Hull.java │ │ │ ├── Polygon.java │ │ │ ├── Quadtree.java │ │ │ └── Voronoi.java │ │ ├── interpolators │ │ │ ├── AbstractInterpolatorFactory.java │ │ │ ├── CallableInterpolator.java │ │ │ ├── Interpolator.java │ │ │ ├── InterpolatorFactory.java │ │ │ ├── Interpolators.java │ │ │ ├── JSNIInterpolatorFactory.java │ │ │ ├── JavascriptFunctionInterpolator.java │ │ │ ├── JavascriptFunctionInterpolatorDecorator.java │ │ │ └── package-info.java │ │ ├── layout │ │ │ ├── Chord.java │ │ │ ├── Cluster.java │ │ │ ├── Force.java │ │ │ ├── HierarchicalLayout.java │ │ │ ├── Layout.java │ │ │ ├── Link.java │ │ │ ├── Node.java │ │ │ └── Tree.java │ │ ├── scales │ │ │ ├── ContinuousQuantitativeScale.java │ │ │ ├── DiscreteQuantitativeScale.java │ │ │ ├── IdentityScale.java │ │ │ ├── LinearScale.java │ │ │ ├── LogScale.java │ │ │ ├── OrdinalScale.java │ │ │ ├── PowScale.java │ │ │ ├── QuantileScale.java │ │ │ ├── QuantitativeScale.java │ │ │ ├── QuantizeScale.java │ │ │ ├── Scale.java │ │ │ ├── Scales.java │ │ │ └── ThresholdScale.java │ │ ├── svg │ │ │ ├── Arc.java │ │ │ ├── Area.java │ │ │ ├── Axis.java │ │ │ ├── Brush.java │ │ │ ├── Chord.java │ │ │ ├── Diagonal.java │ │ │ ├── InterpolationMode.java │ │ │ ├── Line.java │ │ │ ├── PathDataGenerator.java │ │ │ ├── RadialLine.java │ │ │ ├── SVG.java │ │ │ ├── Symbol.java │ │ │ └── SymbolType.java │ │ ├── time │ │ │ ├── Interval.java │ │ │ ├── JsDate.java │ │ │ ├── Time.java │ │ │ ├── TimeFormat.java │ │ │ └── TimeScale.java │ │ ├── tweens │ │ │ └── TweenFunction.java │ │ ├── wrapper │ │ │ ├── D3NodeFactory.java │ │ │ ├── Element.java │ │ │ ├── Inspector.java │ │ │ ├── JavaScriptObject.java │ │ │ ├── JsArrayMixed.java │ │ │ ├── JsArrayNumber.java │ │ │ ├── Node.java │ │ │ ├── NodeList.java │ │ │ ├── Sort.java │ │ │ ├── Style.java │ │ │ ├── Widget.java │ │ │ └── canvas │ │ │ │ ├── CanvasElement.java │ │ │ │ └── Context2d.java │ │ └── xhr │ │ │ └── XmlHttpRequest.java │ │ ├── functionplot │ │ ├── FunctionPlot.java │ │ └── Options.java │ │ ├── javafx │ │ ├── EnumValueProvider.java │ │ ├── FunctionPlotter.java │ │ ├── JavaFxD3Browser.java │ │ ├── JavaFxJsEngine.java │ │ ├── JavaFxJsObject.java │ │ ├── PlotInstruction.java │ │ └── SaveHelper.java │ │ └── plotly │ │ ├── PlotResult.java │ │ ├── Plotly.java │ │ ├── configuration │ │ └── Configuration.java │ │ ├── data │ │ ├── Data.java │ │ ├── Font.java │ │ ├── Marker.java │ │ ├── PlotlyType.java │ │ ├── SingleData.java │ │ ├── contour │ │ │ ├── ColorScale.java │ │ │ ├── Coloring.java │ │ │ ├── Contours.java │ │ │ └── colorbar │ │ │ │ ├── ColorBar.java │ │ │ │ ├── ExponentFormat.java │ │ │ │ ├── HorizontalPosition.java │ │ │ │ ├── LenMode.java │ │ │ │ ├── ShowDetail.java │ │ │ │ ├── TickMode.java │ │ │ │ ├── TickPosition.java │ │ │ │ ├── TitleSide.java │ │ │ │ └── VerticalPosition.java │ │ └── line │ │ │ ├── Dash.java │ │ │ ├── Line.java │ │ │ └── LineShape.java │ │ └── layout │ │ ├── Axis.java │ │ ├── Layout.java │ │ └── margin │ │ ├── Margin.java │ │ └── ZeroMargin.java └── resources │ ├── d3-LICENSE.txt │ ├── d3.min.js │ ├── dictionary.txt │ ├── function-plot-LICENSE.txt │ ├── function-plot.js │ ├── jquery-2.2.4.min.js │ ├── jquery-LICENSE.txt │ ├── nv.d3-LICENSE.txt │ ├── nv.d3.min.css │ ├── nv.d3.min.js │ ├── plotly-LICENSE.txt │ ├── plotly.min.js │ └── plotly_js_fiddle.txt ├── pom.xml └── test ├── java └── .gitignore └── resources └── .gitignore /.gitignore: -------------------------------------------------------------------------------- 1 | .metadata 2 | .dbeaver-temp 3 | .recommenders 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Stefan Eidelloth 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * The name Stefan Eidelloth may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL STEFAN EIDELLOTH BE LIABLE FOR ANY DIRECT, 21 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /javafx-d3-demo/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | -------------------------------------------------------------------------------- /javafx-d3-demo/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | javafx-d3-demo 4 | 5 | 6 | javafx-d3 7 | 8 | 9 | 10 | org.eclipse.jdt.core.javabuilder 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Builder 16 | 17 | 18 | 19 | 20 | 21 | org.eclipse.m2e.core.maven2Nature 22 | org.eclipse.jdt.core.javanature 23 | 24 | 25 | -------------------------------------------------------------------------------- /javafx-d3-demo/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | formatter_profile=_javafx-d3 3 | formatter_settings_version=12 4 | -------------------------------------------------------------------------------- /javafx-d3-demo/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /pom.xml.releaseBackup 4 | /release.properties 5 | /target 6 | /pom.xml.next 7 | /pom.xml.tag 8 | gwt-unitCache/ 9 | d3demo/ -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/demo/CaliforniaJson.java: -------------------------------------------------------------------------------- 1 | 2 | package org.treez.javafxd3.d3.demo; 3 | 4 | public interface CaliforniaJson extends TextResource { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/demo/Data.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.demo; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * An exemple data parsed from the file test-data/readme.csv 7 | * 8 | */ 9 | public class Data { 10 | 11 | //#region ATTRIBUTES 12 | private final String symbol; 13 | 14 | private final Date date; 15 | 16 | private final double price; 17 | 18 | //#end region 19 | 20 | //#region CONSTRUCTORS 21 | 22 | /** 23 | * Constructor 24 | * 25 | * @param symbol 26 | * @param date 27 | * @param price 28 | */ 29 | public Data(final String symbol, final Date date, final double price) { 30 | super(); 31 | this.symbol = symbol; 32 | this.date = date; 33 | this.price = price; 34 | } 35 | 36 | //#end region 37 | 38 | //#region METHODS 39 | 40 | @Override 41 | public String toString() { 42 | return "Data [date=" + date.getTime() + ", price=" + price + "]"; 43 | } 44 | 45 | //#end region 46 | 47 | //#region ACCESSORS 48 | 49 | /** 50 | * @return 51 | */ 52 | public String getSymbol() { 53 | return symbol; 54 | } 55 | 56 | /** 57 | * @return 58 | */ 59 | public Date getDate() { 60 | return date; 61 | } 62 | 63 | /** 64 | * @return 65 | */ 66 | public double getPrice() { 67 | return price; 68 | } 69 | 70 | //#end region 71 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/demo/DemoCase.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.demo; 2 | 3 | 4 | /** 5 | * Represents a demo case that can be used with the JavaFxD3DemoSuite. 6 | */ 7 | public interface DemoCase { 8 | 9 | /** 10 | * Starts the demo 11 | */ 12 | public void start(); 13 | 14 | /** 15 | * Stops the demo 16 | */ 17 | public void stop(); 18 | } 19 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/demo/DemoFactory.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.demo; 2 | 3 | /** 4 | * Creates a new instance of a javafx-d3 demo that is used with the JavaFxD3DemoSuite 5 | */ 6 | public abstract class DemoFactory { 7 | 8 | /** 9 | * Creates a new demo case instance 10 | * @return 11 | */ 12 | public abstract DemoCase newInstance(); 13 | 14 | /** 15 | * Creates an id for the demo case 16 | * @return 17 | */ 18 | public String id() { 19 | String name = this.getClass().getName(); 20 | name = name.substring(name.lastIndexOf('.') + 1); 21 | // inner class 22 | if (name.contains("$")) { 23 | name = name.substring(0, name.lastIndexOf("$")); 24 | } 25 | return name; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/demo/Margin.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.demo; 2 | 3 | public class Margin { 4 | 5 | //#region ATTRIBUTES 6 | 7 | public final int top; 8 | 9 | public final int right; 10 | 11 | public final int bottom; 12 | 13 | public final int left; 14 | 15 | //#end region 16 | 17 | //#region CONSTRUCTORS 18 | 19 | public Margin(final int top, final int right, final int bottom, 20 | final int left) { 21 | super(); 22 | this.top = top; 23 | this.right = right; 24 | this.bottom = bottom; 25 | this.left = left; 26 | } 27 | 28 | //#end region 29 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/demo/TextResource.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.demo; 2 | 3 | /** 4 | * Used by CaliforniaJson 5 | * 6 | */ 7 | public interface TextResource { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/demo/firebug_lite_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

What Can JavaScript Do?

6 | 7 |

JavaScript can change HTML content.

8 | 9 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/.gitignore: -------------------------------------------------------------------------------- 1 | /LineChartDemo.java 2 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/arcTween/ArcTweenDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.arcTween; 2 | 3 | import org.treez.javafxd3.d3.arrays.Array; 4 | import org.treez.javafxd3.d3.core.ConversionUtil; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | import org.treez.javafxd3.d3.svg.Arc; 7 | 8 | import org.treez.javafxd3.d3.core.JsEngine; 9 | 10 | public class ArcTweenDataFunction implements DataFunction { 11 | 12 | private JsEngine engine; 13 | private ArcTween arcTween; 14 | 15 | public ArcTweenDataFunction(JsEngine engine, ArcTween arcTween) { 16 | this.engine = engine; 17 | this.arcTween = arcTween; 18 | 19 | } 20 | 21 | @Override 22 | public String apply(Object context, Object datum, int index) { 23 | 24 | Arc oldArc = ConversionUtil.convertObjectTo(datum, Arc.class, engine); 25 | 26 | Arc newArc = Arc.copy(engine, oldArc) // 27 | .endAngle(arcTween.getNewAngle()); 28 | 29 | Arc arc = arcTween.getArc(); 30 | 31 | Array point = arc.centroid(newArc, index); 32 | Double x = point.get(0, Double.class); 33 | Double y = point.get(1, Double.class); 34 | 35 | int textWidth = arcTween.getTextWidth(); 36 | String translateCommand = "translate(" + (x - textWidth / 2) + "," + y + ")"; 37 | return translateCommand; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/arcTween/ArcTweenInterpolator.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.arcTween; 2 | 3 | import org.treez.javafxd3.d3.interpolators.CallableInterpolator; 4 | import org.treez.javafxd3.d3.interpolators.Interpolator; 5 | import org.treez.javafxd3.d3.interpolators.Interpolators; 6 | import org.treez.javafxd3.d3.svg.Arc; 7 | 8 | import org.treez.javafxd3.d3.core.JsEngine; 9 | 10 | public class ArcTweenInterpolator extends CallableInterpolator { 11 | 12 | private ArcTweenFunction arcTweenFunction; 13 | private Interpolator interpolator; 14 | 15 | public ArcTweenInterpolator(JsEngine engine, ArcTweenFunction arcTweenFunction) { 16 | super(engine); 17 | this.arcTweenFunction = arcTweenFunction; 18 | interpolator = Interpolators.interpolateNumber(engine, arcTweenFunction.getEndAngle(), arcTweenFunction.getNewAngle()); 19 | } 20 | 21 | @Override 22 | public String interpolate(Object t) { 23 | 24 | double interpolated = interpolator.interpolate(t); 25 | 26 | Arc arcDatum = arcTweenFunction.getArcDatum(); 27 | arcDatum.endAngle(interpolated); 28 | Arc arc = arcTweenFunction.getArc(); 29 | return arc.generate(arcDatum); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/axis/AxisComponent.css: -------------------------------------------------------------------------------- 1 | 2 | text{ 3 | font: 10px sans-serif; 4 | } 5 | 6 | .svg { 7 | 8 | margin: 0; 9 | } 10 | 11 | path.line { 12 | fill: none; 13 | stroke: #666; 14 | stroke-width: 1.5px; 15 | } 16 | 17 | .area { 18 | fill: #e7e7e7; 19 | } 20 | 21 | .axis { 22 | shape-rendering: crispEdges; 23 | } 24 | 25 | .x.axis line { 26 | stroke: #fff; 27 | } 28 | 29 | .x.axis .minor { 30 | stroke-opacity: .5; 31 | } 32 | 33 | .x.axis path { 34 | display: none; 35 | } 36 | 37 | .y.axis line, .y.axis path { 38 | fill: none; 39 | stroke: #000; 40 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/axis/DataDsvObjectAccessor.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.axis; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.core.Value; 6 | import org.treez.javafxd3.d3.dsv.DsvObjectAccessor; 7 | import org.treez.javafxd3.d3.dsv.DsvRow; 8 | import org.treez.javafxd3.d3.time.JsDate; 9 | import org.treez.javafxd3.d3.time.TimeFormat; 10 | 11 | public class DataDsvObjectAccessor implements DsvObjectAccessor { 12 | 13 | //#region ATTRIBUTES 14 | 15 | private JsEngine engine; 16 | private TimeFormat format; 17 | 18 | //#end region 19 | 20 | //#region CONSTRUCTORS 21 | 22 | public DataDsvObjectAccessor(JsEngine engine, TimeFormat format){ 23 | this.engine = engine; 24 | this.format = format; 25 | } 26 | 27 | //#end region 28 | 29 | //#region METHODS 30 | 31 | @Override 32 | public DsvData apply(Object row, int index) { 33 | 34 | DsvRow dsvRow = ConversionUtil.convertObjectTo(row, DsvRow.class, engine); 35 | 36 | Value value = dsvRow.get("symbol"); 37 | 38 | if ("S&P 500".equals(value.asString())) { 39 | String symbol = dsvRow.get("symbol").asString(); 40 | JsDate date = format.parse(dsvRow.get("date").asString()); 41 | double price = dsvRow.get("price").asDouble(); 42 | return new DsvData(engine, symbol, date, price); 43 | } else { 44 | return null; 45 | } 46 | } 47 | 48 | //#end region 49 | 50 | } 51 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/barchart/BarChart.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 10px sans-serif; 3 | } 4 | 5 | .x { 6 | } 7 | 8 | .y { 9 | } 10 | 11 | .axis path, 12 | .axis line { 13 | fill: none; 14 | stroke: #000; 15 | shape-rendering: crispEdges; 16 | } 17 | 18 | .bar { 19 | fill: steelblue; 20 | } 21 | 22 | .x.axis path { 23 | display: none; 24 | } 25 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/barchart/BarChartData.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.barchart; 2 | 3 | public class BarChartData { 4 | 5 | //#region ATTRIBUTES 6 | 7 | private String letter; 8 | private double frequency; 9 | 10 | //#end region 11 | 12 | //#region CONSTRUCTORS 13 | 14 | public BarChartData(final String letter, final double frequency) { 15 | super(); 16 | 17 | this.letter = letter; 18 | this.frequency = frequency; 19 | } 20 | 21 | //#end region 22 | 23 | //#region ACCESSORS 24 | 25 | public String getLetter() { 26 | return letter; 27 | } 28 | 29 | public double getFrequency() { 30 | return frequency; 31 | } 32 | 33 | //#end region 34 | 35 | } 36 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/barchart/BarChartObjectAccessor.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.barchart; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.dsv.DsvObjectAccessor; 6 | import org.treez.javafxd3.d3.dsv.DsvRow; 7 | 8 | public class BarChartObjectAccessor implements DsvObjectAccessor { 9 | 10 | private JsEngine engine; 11 | 12 | public BarChartObjectAccessor(JsEngine engine){ 13 | this.engine=engine; 14 | 15 | } 16 | 17 | @Override 18 | public BarChartData apply(final Object datum, final int index) { 19 | 20 | DsvRow dsvRow = ConversionUtil.convertObjectTo(datum, DsvRow.class, engine); 21 | 22 | String letter = dsvRow.get("letter").asString(); 23 | Double frequency = dsvRow.get("frequency").asDouble(); 24 | 25 | return new BarChartData(letter, frequency); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/behaviors/ZoomDemo.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | svg { 4 | font: 10px sans-serif; 5 | shape-rendering: crispEdges; 6 | } 7 | 8 | rect { 9 | fill: #ddd; 10 | } 11 | 12 | .axis path, 13 | .axis line { 14 | fill: none; 15 | stroke: #fff; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/chorddiagram/ChordDiagram.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 10px sans-serif; 3 | } 4 | 5 | .chord path { 6 | fill-opacity: .67; 7 | stroke: #000; 8 | stroke-width: .5px; 9 | } 10 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/chorddiagram/GroupTick.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.chorddiagram; 2 | 3 | import org.treez.javafxd3.d3.D3; 4 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 5 | 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | import org.treez.javafxd3.d3.core.JsObject; 8 | 9 | public class GroupTick extends JavaScriptObject { 10 | 11 | //#region CONSCTRUCTORS 12 | 13 | public GroupTick(JsEngine engine, JsObject wrappedJsObject) { 14 | super(engine, wrappedJsObject); 15 | } 16 | 17 | //#end region 18 | 19 | //#region METHODS 20 | 21 | public static GroupTick create(double angle, String label, JsEngine engine) { 22 | 23 | D3 d3 = new D3(engine); 24 | 25 | String command = "d3.new_group_tick = {" + // 26 | "angle: " + angle + ", " + // 27 | "label: '" + label + "'" + // 28 | "};"; 29 | 30 | d3.eval(command); 31 | JsObject result = d3.evalForJsObject("d3.new_group_tick"); 32 | 33 | d3.eval("d3.new_group_tick=undefined"); 34 | return new GroupTick(engine, result); 35 | } 36 | 37 | //#end region 38 | 39 | //#region ACCESSORS 40 | 41 | public double angle() { 42 | Double angle = getMemberForDouble("angle"); 43 | return angle; 44 | } 45 | 46 | public String label() { 47 | String label = getMemberForString("label"); 48 | return label; 49 | } 50 | 51 | //#end region 52 | 53 | } 54 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/focus/FocusAndContext.css: -------------------------------------------------------------------------------- 1 | 2 | svg { 3 | font: 10px sans-serif; 4 | } 5 | 6 | path { 7 | fill: steelblue; 8 | } 9 | 10 | .axis path, 11 | .axis line { 12 | fill: none; 13 | stroke: #000; 14 | shape-rendering: crispEdges; 15 | } 16 | 17 | .brush .extent { 18 | stroke: #fff; 19 | fill-opacity: .125; 20 | shape-rendering: crispEdges; 21 | } 22 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/focus/FocusAndContextData.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.focus; 2 | 3 | import org.treez.javafxd3.d3.time.JsDate; 4 | 5 | public class FocusAndContextData { 6 | 7 | //#region ATTRIOBUTES 8 | 9 | private final JsDate date; 10 | 11 | private final double price; 12 | 13 | //#end region 14 | 15 | //#region CONSTRUCTORS 16 | 17 | public FocusAndContextData(final JsDate date, final double price) { 18 | super(); 19 | this.date = date; 20 | this.price = price; 21 | } 22 | 23 | //#end region 24 | 25 | //#region ACCESSORS 26 | 27 | public JsDate getDate() { 28 | return date; 29 | } 30 | 31 | public double getPrice() { 32 | return price; 33 | } 34 | 35 | //#end region 36 | } 37 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/functionplotter/FunctionPlotDemo.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.functionplotter; 2 | 3 | import org.treez.javafxd3.d3.D3; 4 | import org.treez.javafxd3.d3.demo.AbstractDemoCase; 5 | import org.treez.javafxd3.d3.demo.DemoCase; 6 | import org.treez.javafxd3.d3.demo.DemoFactory; 7 | import org.treez.javafxd3.functionplot.FunctionPlot; 8 | import org.treez.javafxd3.functionplot.Options; 9 | 10 | import javafx.scene.layout.VBox; 11 | 12 | public class FunctionPlotDemo extends AbstractDemoCase { 13 | 14 | //#region CONSTRUCTORS 15 | 16 | public FunctionPlotDemo(D3 d3, VBox demoPreferenceBox) { 17 | super(d3, demoPreferenceBox); 18 | } 19 | 20 | //#end region 21 | 22 | //#region METHODS 23 | 24 | public static DemoFactory factory(D3 d3, VBox demoPreferenceBox) { 25 | return new DemoFactory() { 26 | @Override 27 | public DemoCase newInstance() { 28 | return new FunctionPlotDemo(d3, demoPreferenceBox); 29 | } 30 | }; 31 | } 32 | 33 | @Override 34 | public void start() { 35 | 36 | getSvg() // 37 | .attr("width", 700) // 38 | .attr("height", 400); 39 | 40 | Options options = new Options(engine) // 41 | .setTarget("#svg") // 42 | .setDataExpression("[{fn: 'exp(-x^2)'}]"); 43 | 44 | FunctionPlot functionPlot = new FunctionPlot(engine); 45 | functionPlot.apply(options); 46 | 47 | } 48 | 49 | @Override 50 | public void stop() { 51 | 52 | } 53 | 54 | //#end region 55 | 56 | } 57 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/geom/hull/HullCoords.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.geom.hull; 2 | 3 | import org.treez.javafxd3.d3.coords.Coords; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class HullCoords extends Coords { 9 | 10 | //#region CONSTRUCTORS 11 | 12 | public HullCoords(JsEngine engine, JsObject wrappedJsObject) { 13 | super(engine, wrappedJsObject); 14 | } 15 | 16 | public HullCoords(JsEngine engine, double x, double y) { 17 | super(engine, x, y); 18 | } 19 | 20 | //#end region 21 | 22 | //#region METHODS 23 | 24 | @Override 25 | public String toString() { 26 | return x() + "," + y(); 27 | } 28 | 29 | //#end region 30 | 31 | } 32 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/geom/hull/HullDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.geom.hull; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.treez.javafxd3.d3.arrays.Array; 7 | import org.treez.javafxd3.d3.core.ConversionUtil; 8 | import org.treez.javafxd3.d3.core.JsEngine; 9 | import org.treez.javafxd3.d3.core.JsObject; 10 | import org.treez.javafxd3.d3.functions.DataFunction; 11 | 12 | public class HullDataFunction implements DataFunction { 13 | 14 | //#region ATTRIBUTES 15 | 16 | private JsEngine engine; 17 | 18 | //#end region 19 | 20 | //#region CONSTRUCTORS 21 | 22 | public HullDataFunction(JsEngine engine) { 23 | this.engine = engine; 24 | } 25 | 26 | //#end region 27 | 28 | //#region METHODS 29 | 30 | @Override 31 | public String apply(final Object context, final Object datum, final int i) { 32 | 33 | @SuppressWarnings("unchecked") 34 | Array coordsList = (Array) ConversionUtil.convertObjectTo(datum, Array.class, engine); 35 | 36 | int size = coordsList.sizes().get(1); 37 | 38 | List coordsStringList = new ArrayList<>(); 39 | for (int index = 0; index < size; index++) { 40 | JsObject jsCoords = coordsList.get(index, JsObject.class); 41 | HullCoords coords = new HullCoords(engine, jsCoords); 42 | String coordsString = coords.toString(); 43 | coordsStringList.add(coordsString); 44 | } 45 | String coordsString = String.join("L", coordsStringList); 46 | String result = "M" + coordsString + "Z"; 47 | return result; 48 | 49 | } 50 | 51 | //#end region 52 | 53 | } 54 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/geom/hull/HullDemo.css: -------------------------------------------------------------------------------- 1 | rect.hulldemo { 2 | fill: none; 3 | pointer-events: all; 4 | stroke: black; 5 | stroke-width: 1px; 6 | } 7 | 8 | .hulldemo { 9 | fill: steelblue; 10 | stroke: steelblue; 11 | stroke-width: 32px; 12 | stroke-linejoin: round; 13 | } 14 | 15 | circle.hulldemo { 16 | fill: white; 17 | stroke: black; 18 | stroke-width: 1.5px; 19 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/geom/hull/HullMouseClickDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.geom.hull; 2 | 3 | import java.util.List; 4 | 5 | import org.treez.javafxd3.d3.D3; 6 | import org.treez.javafxd3.d3.core.ConversionUtil; 7 | import org.treez.javafxd3.d3.functions.DataFunction; 8 | import org.treez.javafxd3.d3.wrapper.Element; 9 | 10 | import org.treez.javafxd3.d3.core.JsEngine; 11 | 12 | public class HullMouseClickDataFunction implements DataFunction { 13 | 14 | //#region ATTRIBUTES 15 | 16 | private JsEngine engine; 17 | 18 | private List vertices; 19 | 20 | private D3 d3; 21 | 22 | private Runnable redrawRunnable; 23 | 24 | //#end region 25 | 26 | //#region CONSTRUCTORS 27 | 28 | public HullMouseClickDataFunction( 29 | JsEngine engine, 30 | List vertices, 31 | D3 d3, 32 | Runnable redrawRunnable 33 | ){ 34 | this.engine=engine; 35 | this.vertices = vertices; 36 | this.d3 = d3; 37 | this.redrawRunnable=redrawRunnable; 38 | } 39 | 40 | //#end region 41 | 42 | //#region METHODS 43 | 44 | @Override 45 | public Void apply(final Object context, final Object d, final int index) { 46 | 47 | Element element = ConversionUtil.convertObjectTo(context, Element.class, engine); 48 | HullCoords coords = new HullCoords(engine, d3.mouseX(element), d3.mouseY(element)); 49 | vertices.add(coords); 50 | redrawRunnable.run(); 51 | return null; 52 | 53 | } 54 | 55 | //#end region 56 | 57 | } 58 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/geom/hull/HullMouseMoveDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.geom.hull; 2 | 3 | import java.util.List; 4 | 5 | import org.treez.javafxd3.d3.D3; 6 | import org.treez.javafxd3.d3.core.ConversionUtil; 7 | import org.treez.javafxd3.d3.functions.DataFunction; 8 | import org.treez.javafxd3.d3.wrapper.Element; 9 | 10 | import org.treez.javafxd3.d3.core.JsEngine; 11 | 12 | public class HullMouseMoveDataFunction implements DataFunction { 13 | 14 | //#region ATTRIBUTES 15 | 16 | private JsEngine engine; 17 | 18 | private List vertices; 19 | 20 | private D3 d3; 21 | 22 | private Runnable redrawRunnable; 23 | 24 | //#end region 25 | 26 | //#region CONSTRUCTORS 27 | 28 | public HullMouseMoveDataFunction( 29 | JsEngine engine, 30 | List vertices, 31 | D3 d3, 32 | Runnable redrawRunnable 33 | ){ 34 | this.engine=engine; 35 | this.vertices = vertices; 36 | this.d3 = d3; 37 | this.redrawRunnable=redrawRunnable; 38 | } 39 | 40 | //#end region 41 | 42 | //#region METHODS 43 | 44 | @Override 45 | public Void apply(final Object context, final Object d, final int index) { 46 | 47 | Element element = ConversionUtil.convertObjectTo(context, Element.class, engine); 48 | HullCoords coords = new HullCoords(engine, d3.mouseX(element), d3.mouseY(element)); 49 | vertices.set(0, coords); 50 | redrawRunnable.run(); 51 | return null; 52 | } 53 | 54 | //#end region 55 | 56 | } 57 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/geom/hull/HullTransformDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.geom.hull; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | 7 | public class HullTransformDataFunction implements DataFunction { 8 | 9 | //#region ATTRIBUTES 10 | 11 | private JsEngine engine; 12 | 13 | //#end region 14 | 15 | //#region CONSTRUCTORS 16 | 17 | public HullTransformDataFunction(JsEngine engine) { 18 | this.engine = engine; 19 | } 20 | 21 | //#end region 22 | 23 | //#region METHODS 24 | 25 | @Override 26 | public String apply(Object context, Object datum, int index) { 27 | 28 | try { 29 | HullCoords coords = ConversionUtil.convertObjectTo(datum, HullCoords.class, engine); 30 | String result = "translate(" + coords.toString() + ")"; 31 | return result; 32 | } catch (Exception exception) { 33 | return "translate(0,0)"; 34 | } 35 | 36 | } 37 | 38 | //#end region 39 | 40 | } 41 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/geom/mitchell/Circle.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.geom.mitchell; 2 | 3 | public class Circle { 4 | 5 | //#region ATTRIBUTES 6 | 7 | public double x; 8 | public double y; 9 | public double r; 10 | 11 | //#end region 12 | 13 | //#region CONSTRUCTORS 14 | 15 | public Circle(final double x, final double y, final double r) { 16 | super(); 17 | this.x = x; 18 | this.y = y; 19 | this.r = r; 20 | } 21 | 22 | //#end region 23 | 24 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/geom/mitchell/CircleGenerator.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.geom.mitchell; 2 | 3 | public interface CircleGenerator { 4 | 5 | public Circle generate(double k); 6 | 7 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/geom/voronoi/VoronoiTessellationDemo.css: -------------------------------------------------------------------------------- 1 | 2 | .vt path { 3 | stroke: #fff; 4 | } 5 | 6 | .vt path:first-child { 7 | fill: yellow !important; 8 | } 9 | 10 | .vt circle { 11 | fill: #000; 12 | pointer-events: none; 13 | } 14 | 15 | .q0-9 { fill: rgb(197,27,125); } 16 | .q1-9 { fill: rgb(222,119,174); } 17 | .q2-9 { fill: rgb(241,182,218); } 18 | .q3-9 { fill: rgb(253,224,239); } 19 | .q4-9 { fill: rgb(247,247,247); } 20 | .q5-9 { fill: rgb(230,245,208); } 21 | .q6-9 { fill: rgb(184,225,134); } 22 | .q7-9 { fill: rgb(127,188,65); } 23 | .q8-9 { fill: rgb(77,146,33); } 24 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/helloworld/HelloWorldDemo.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.helloworld; 2 | 3 | import org.treez.javafxd3.d3.D3; 4 | import org.treez.javafxd3.d3.core.Selection; 5 | import org.treez.javafxd3.d3.demo.AbstractDemoCase; 6 | import org.treez.javafxd3.d3.demo.DemoCase; 7 | import org.treez.javafxd3.d3.demo.DemoFactory; 8 | 9 | import javafx.scene.layout.VBox; 10 | 11 | public class HelloWorldDemo extends AbstractDemoCase { 12 | 13 | //#region CONSTRUCTORS 14 | 15 | public HelloWorldDemo(D3 d3, VBox demoPreferenceBox) { 16 | super(d3, demoPreferenceBox); 17 | } 18 | 19 | //#end region 20 | 21 | //#region METHODS 22 | 23 | public static DemoFactory factory(D3 d3, VBox demoPreferenceBox) { 24 | return new DemoFactory() { 25 | @Override 26 | public DemoCase newInstance() { 27 | return new HelloWorldDemo(d3, demoPreferenceBox); 28 | } 29 | }; 30 | } 31 | 32 | @Override 33 | public void start() { 34 | 35 | Selection svg = getSvg(); 36 | 37 | svg // 38 | .attr("width", 700)// 39 | .attr("height", 400); 40 | 41 | svg // 42 | .append("text") // 43 | .attr("x", "0") // 44 | .attr("y", "15") // 45 | .text("Hello World"); 46 | 47 | } 48 | 49 | @Override 50 | public void stop() { 51 | 52 | } 53 | 54 | //#end region 55 | 56 | } 57 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/layout/ClusterDendogram.css: -------------------------------------------------------------------------------- 1 | .node circle { 2 | fill: #fff; 3 | stroke: steelblue; 4 | stroke-width: 1.5px; 5 | } 6 | 7 | .node { 8 | font: 10px sans-serif; 9 | } 10 | 11 | .link { 12 | fill: none; 13 | stroke: #ccc; 14 | stroke-width: 1.5px; 15 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/brush/ordinal/OrdinalBrushingDemo.css: -------------------------------------------------------------------------------- 1 | 2 | .ob svg { 3 | font: 10px sans-serif; 4 | } 5 | 6 | .ob path { 7 | -webkit-transition: fill-opacity 250ms linear; 8 | } 9 | 10 | .selecting path { 11 | fill-opacity: .2; 12 | } 13 | 14 | .selecting path.selected { 15 | stroke: #f00; 16 | stroke-width: 2px; 17 | } 18 | 19 | .axis path, .axis line { 20 | fill: none; 21 | stroke: #000; 22 | shape-rendering: crispEdges; 23 | } 24 | 25 | .brush .extent { 26 | stroke: #fff; 27 | fill-opacity: .125; 28 | shape-rendering: crispEdges; 29 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/brush/scatter/BrushEndFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.svg.brush.scatter; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | import javafx.application.Platform; 6 | 7 | public class BrushEndFunction implements DataFunction { 8 | 9 | private ScatterPlotMatrixDemo scatterPlotMatrixDemo; 10 | 11 | public BrushEndFunction(ScatterPlotMatrixDemo scatterPlotMatrixDemo) { 12 | this.scatterPlotMatrixDemo = scatterPlotMatrixDemo; 13 | 14 | } 15 | 16 | @Override 17 | public Void apply(Object context, Object d, int index) { 18 | Platform.runLater(() -> { 19 | scatterPlotMatrixDemo.brushEnd(); 20 | }); 21 | return null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/brush/scatter/BrushMoveFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.svg.brush.scatter; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | import javafx.application.Platform; 6 | 7 | public class BrushMoveFunction implements DataFunction { 8 | 9 | private ScatterPlotMatrixDemo scatterPlotMatrixDemo; 10 | 11 | public BrushMoveFunction(ScatterPlotMatrixDemo scatterPlotMatrixDemo) { 12 | this.scatterPlotMatrixDemo = scatterPlotMatrixDemo; 13 | } 14 | 15 | @Override 16 | public Void apply(Object context, Object d, int index) { 17 | Platform.runLater(() -> { 18 | Point point = (Point) d; 19 | scatterPlotMatrixDemo.brushMove(point); 20 | }); 21 | return null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/brush/scatter/BrushStartFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.svg.brush.scatter; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | import org.treez.javafxd3.d3.wrapper.Element; 7 | 8 | import javafx.application.Platform; 9 | 10 | public class BrushStartFunction implements DataFunction { 11 | 12 | private ScatterPlotMatrixDemo scatterPlotMatrixDemo; 13 | private JsEngine engine; 14 | 15 | public BrushStartFunction(ScatterPlotMatrixDemo scatterPlotMatrixDemo, JsEngine engine){ 16 | this.scatterPlotMatrixDemo=scatterPlotMatrixDemo; 17 | this.engine=engine; 18 | } 19 | 20 | @Override 21 | public Void apply(Object context, Object d, int index) { 22 | Platform.runLater(()->{ 23 | 24 | Element element = ConversionUtil.convertObjectTo(context, Element.class, engine); 25 | Point point = (Point) d; 26 | 27 | scatterPlotMatrixDemo.brushStart(element, point); 28 | 29 | }); 30 | 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/brush/scatter/Point.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.svg.brush.scatter; 2 | 3 | public class Point { 4 | 5 | public String xTrait; 6 | public String yTrait; 7 | public double i; 8 | public double j; 9 | 10 | public Point(final String xTrait, final String yTrait, final int i, final int j) { 11 | super(); 12 | this.xTrait = xTrait; 13 | this.yTrait = yTrait; 14 | this.i = i; 15 | this.j = j; 16 | } 17 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/brush/scatter/ScatterPlotMatrixDemo.css: -------------------------------------------------------------------------------- 1 | @external .extent; 2 | 3 | svg { 4 | font: 10px sans-serif; 5 | padding: 10px; 6 | } 7 | 8 | .axis, 9 | .frame { 10 | shape-rendering: crispEdges; 11 | } 12 | 13 | .axis line { 14 | stroke: #ddd; 15 | } 16 | 17 | .axis path { 18 | display: none; 19 | } 20 | 21 | .frame { 22 | fill: none; 23 | stroke: #aaa; 24 | } 25 | 26 | circle { 27 | fill-opacity: .7; 28 | } 29 | 30 | circle.hidden { 31 | fill: #ccc !important; 32 | } 33 | 34 | .extent { 35 | fill: #000; 36 | fill-opacity: .125; 37 | stroke: #fff; 38 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/brush/slider/BrushAsSliderDemo.css: -------------------------------------------------------------------------------- 1 | 2 | .axis { 3 | font: 10px sans-serif; 4 | -webkit-user-select: none; 5 | -moz-user-select: none; 6 | user-select: none; 7 | } 8 | 9 | .axis .domain { 10 | fill: none; 11 | stroke: #000; 12 | stroke-opacity: .3; 13 | stroke-width: 10px; 14 | stroke-linecap: round; 15 | } 16 | 17 | .axis .halo { 18 | fill: none; 19 | stroke: #ddd; 20 | stroke-width: 8px; 21 | stroke-linecap: round; 22 | } 23 | 24 | .slider .handle { 25 | fill: #fff; 26 | stroke: #000; 27 | stroke-opacity: .5; 28 | stroke-width: 1.25px; 29 | cursor: crosshair; 30 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/brush/transitions/BrushTransitionsDemo.css: -------------------------------------------------------------------------------- 1 | 2 | svg { 3 | font: 10px sans-serif; 4 | } 5 | 6 | path { 7 | -webkit-transition: fill-opacity 250ms linear; 8 | } 9 | 10 | .selecting path { 11 | fill-opacity: .2; 12 | } 13 | 14 | .selecting path.selected { 15 | stroke: #f00; 16 | stroke-width: 2px; 17 | } 18 | 19 | .axis path, .axis line { 20 | fill: none; 21 | stroke: #000; 22 | shape-rendering: crispEdges; 23 | } 24 | 25 | .brush .extent { 26 | stroke: #fff; 27 | fill-opacity: .125; 28 | shape-rendering: crispEdges; 29 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/brush/transitions/BrushTransitionsDemoCallback.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.svg.brush.transitions; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.democases.svg.brush.transitions.BrushTransitionsDemo.Point; 6 | import org.treez.javafxd3.d3.geom.Quadtree.Callback; 7 | import org.treez.javafxd3.d3.geom.Quadtree.RootNode; 8 | 9 | public class BrushTransitionsDemoCallback implements Callback { 10 | 11 | //#region ATTRIBUTES 12 | 13 | private JsEngine engine; 14 | 15 | private double x0; 16 | private double y0; 17 | private double x3; 18 | private double y3; 19 | 20 | //#end region 21 | 22 | //#region CONSTURCTORS 23 | 24 | public BrushTransitionsDemoCallback(JsEngine engine, final double x0, final double y0, final double x3, 25 | final double y3) { 26 | this.engine = engine; 27 | this.x0 = x0; 28 | this.y0 = y0; 29 | this.x3 = x3; 30 | this.y3 = y3; 31 | } 32 | 33 | //#end region 34 | 35 | //#region METHODS 36 | 37 | @Override 38 | public boolean visit(Object nodeObj, Double x1, Double y1, Double x2, Double y2) { 39 | 40 | 41 | @SuppressWarnings("unchecked") 42 | RootNode node = ConversionUtil.convertObjectTo(nodeObj, RootNode.class, engine); 43 | Point p = node.point(Point.class); 44 | 45 | if (p != null) { 46 | p.setSelected((p.x() >= x0) && (p.x() < x3) && (p.y() >= y0) && (p.y() < y3)); 47 | } 48 | return x1 >= x3 || y1 >= y3 || x2 < x0 || y2 < y0; 49 | } 50 | 51 | //#end region 52 | 53 | } 54 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/line/DefinedDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.svg.line; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | 7 | public class DefinedDataFunction implements DataFunction { 8 | 9 | //#region ATTRIBUTES 10 | 11 | private JsEngine engine; 12 | 13 | //#end region 14 | 15 | //#region CONSTRUCTORS 16 | 17 | public DefinedDataFunction(JsEngine engine){ 18 | this.engine = engine; 19 | } 20 | 21 | //#end region 22 | 23 | //#region METHODS 24 | 25 | @Override 26 | public Boolean apply(Object context, Object datum, int index) { 27 | 28 | CustomCoords coords = ConversionUtil.convertObjectTo(datum, CustomCoords.class, engine); 29 | if (coords!=null){ 30 | boolean defined = coords.defined(); 31 | return defined; 32 | } 33 | return false; 34 | 35 | } 36 | 37 | public Boolean apply(String context, String d, int index){ 38 | return null; 39 | } 40 | 41 | //#end region 42 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/line/LineDemo.css: -------------------------------------------------------------------------------- 1 | path{ 2 | fill: none; 3 | stroke: red; 4 | } 5 | 6 | circle{ 7 | fill: black; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/svg/symbol/SymbolDemo.css: -------------------------------------------------------------------------------- 1 | path.symboldemo { 2 | 3 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/update/GeneralUpdatePattern1.css: -------------------------------------------------------------------------------- 1 | text { 2 | font: bold 48px monospace; 3 | } 4 | 5 | .enter { 6 | fill: green; 7 | } 8 | 9 | .update { 10 | fill: #333; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/update/GeneralUpdatePattern2.css: -------------------------------------------------------------------------------- 1 | text { 2 | font: bold 48px monospace; 3 | } 4 | 5 | .enter { 6 | fill: green; 7 | } 8 | 9 | .update { 10 | fill: #333; 11 | } 12 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/update/GeneralUpdatePattern3.css: -------------------------------------------------------------------------------- 1 | .enter { 2 | fill: green; 3 | font: bold 48px monospace; 4 | } 5 | 6 | .update { 7 | fill: #333; 8 | font: bold 48px monospace; 9 | } 10 | 11 | 12 | .exit { 13 | fill: brown; 14 | font: bold 48px monospace; 15 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/xy/XAxisDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.xy; 2 | 3 | import org.treez.javafxd3.d3.core.Value; 4 | import org.treez.javafxd3.d3.functions.DataFunction; 5 | import org.treez.javafxd3.d3.scales.LinearScale; 6 | 7 | public class XAxisDataFunction implements DataFunction { 8 | 9 | //#region ATTRIBUTES 10 | 11 | private LinearScale xScale; 12 | 13 | private double[] xData; 14 | 15 | //#end region 16 | 17 | //#region CONSTRUCTORS 18 | 19 | public XAxisDataFunction(LinearScale xScale, double[] xData){ 20 | this.xScale = xScale; 21 | this.xData = xData; 22 | } 23 | 24 | //#end region 25 | 26 | //#region METHODS 27 | 28 | @Override 29 | public Double apply(final Object context, final Object d, final int index) { 30 | 31 | Double x = xData[index]; 32 | Value value = xScale.apply(x); 33 | Double result = value.asDouble(); 34 | return result; 35 | } 36 | 37 | //#end region 38 | } 39 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/xy/Xy.css: -------------------------------------------------------------------------------- 1 | 2 | .chart { 3 | 4 | } 5 | 6 | .main { 7 | 8 | } 9 | 10 | .main text { 11 | font: 10px sans-serif; 12 | } 13 | 14 | .axis line, .axis path { 15 | shape-rendering: crispEdges; 16 | stroke: black; 17 | fill: none; 18 | } 19 | 20 | circle { 21 | fill: steelblue; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/d3/democases/xy/YAxisDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.democases.xy; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.core.Value; 6 | import org.treez.javafxd3.d3.functions.DataFunction; 7 | import org.treez.javafxd3.d3.scales.LinearScale; 8 | 9 | public class YAxisDataFunction implements DataFunction { 10 | 11 | //#region ATTRIBUTES 12 | 13 | private JsEngine engine; 14 | 15 | private LinearScale yScale; 16 | 17 | //#end region 18 | 19 | //#region CONSTRUCTORS 20 | 21 | public YAxisDataFunction(JsEngine engine, LinearScale yScale ){ 22 | this.engine=engine; 23 | this.yScale = yScale; 24 | } 25 | 26 | //#end region 27 | 28 | //#region METHODS 29 | 30 | @Override 31 | public Double apply(final Object context, final Object datum, final int index) { 32 | 33 | Double input = ConversionUtil.convertObjectTo(datum, Double.class, engine); 34 | Value value = yScale.apply(input); 35 | Double result = value.asDouble(); 36 | return result; 37 | 38 | } 39 | 40 | //#end region 41 | } 42 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/java/org/treez/javafxd3/javafx/FunctionPlotterDemo.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.javafx; 2 | 3 | import org.treez.javafxd3.javafx.FunctionPlotter; 4 | 5 | import javafx.application.Application; 6 | import javafx.scene.Scene; 7 | import javafx.scene.paint.Color; 8 | import javafx.stage.Stage; 9 | 10 | 11 | public class FunctionPlotterDemo extends Application { 12 | 13 | //#region METHODS 14 | 15 | 16 | public static void main(String[] args) { 17 | launch(args); 18 | } 19 | 20 | @Override 21 | public void start(Stage stage) { 22 | 23 | //set stage title 24 | stage.setTitle("Functionplotter demo"); 25 | 26 | //create function plotter 27 | FunctionPlotter functionPlotter = new FunctionPlotter(); 28 | functionPlotter.setXDomain(-2,2); 29 | functionPlotter.setYDomain(-0.2,1.2); 30 | functionPlotter.plot("exp(-x^2)"); 31 | 32 | //create the scene 33 | Scene scene = new Scene(functionPlotter, 750, 500, Color.web("#666970")); 34 | stage.setScene(scene); 35 | stage.show(); 36 | } 37 | 38 | //#end region 39 | 40 | } 41 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/resources/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /pom.xml.releaseBackup 4 | /release.properties 5 | /target 6 | /pom.xml.next 7 | /pom.xml.tag 8 | d3demo/ -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/resources/demo-data/data.tsv: -------------------------------------------------------------------------------- 1 | letter frequency 2 | A .08167 3 | B .01492 4 | C .02780 5 | D .04253 6 | E .12702 7 | F .02288 8 | G .02022 9 | H .06094 10 | I .06973 11 | J .00153 12 | K .00747 13 | L .04025 14 | M .02517 15 | N .06749 16 | O .07507 17 | P .01929 18 | Q .00098 19 | R .05987 20 | S .06333 21 | T .09056 22 | U .02758 23 | V .01037 24 | W .02465 25 | X .00150 26 | Y .01971 27 | Z .00074 -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/resources/test-data/test.csv: -------------------------------------------------------------------------------- 1 | Name,Age 2 | Paul,25 3 | John,38 4 | Jane,15 5 | Bruce,48 6 | Emma,28 -------------------------------------------------------------------------------- /javafx-d3-demo/src/main/resources/test-data/test.tsv: -------------------------------------------------------------------------------- 1 | Name Age 2 | Paul 25 3 | John 38 4 | Jane 15 5 | Bruce 48 6 | Emma 28 7 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/D3Test.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class D3Test extends AbstractTestCase { 7 | 8 | @Override 9 | public void doTest() { 10 | version(); 11 | shuffle(); 12 | } 13 | 14 | private void version() { 15 | 16 | String version = d3.version(); 17 | System.out.println("Using D3 version " + version); 18 | assertEquals("3.5.9", version); 19 | } 20 | 21 | private void shuffle() { 22 | 23 | // for char array 24 | char[] a = { 'a', 'b', 'c', 'd' }; 25 | d3.shuffle(a); 26 | 27 | boolean isSorted = checkIfArrayIsStillSorted(a); 28 | if (isSorted) { 29 | fail("shuffle did not work"); 30 | } 31 | 32 | // for list 33 | List array = Arrays.asList("1", "2", "3", "4"); 34 | d3.shuffle(array); 35 | assertNotSorted(array); 36 | } 37 | 38 | private boolean checkIfArrayIsStillSorted(char[] a) { 39 | boolean sorted = true; 40 | char previous = 0; 41 | for (char c : a) { 42 | if (c < previous) { 43 | sorted = false; 44 | break; 45 | } 46 | previous = c; 47 | } 48 | return sorted; 49 | } 50 | 51 | private > void assertNotSorted(final Iterable array) { 52 | T previous = null; 53 | for (T comparable : array) { 54 | // when one element found is not sorted 55 | if ((previous != null) && (comparable.compareTo(previous) < 0)) { 56 | return; 57 | } 58 | previous = comparable; 59 | } 60 | fail("shuffle did not work"); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/color/HslColorTest.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.color; 2 | 3 | import org.treez.javafxd3.d3.color.Colors; 4 | import org.treez.javafxd3.d3.color.HSLColor; 5 | import org.treez.javafxd3.d3.color.RGBColor; 6 | 7 | import org.treez.javafxd3.d3.AbstractTestCase; 8 | 9 | /** 10 | * Tests the class HslColor 11 | */ 12 | public class HslColorTest extends AbstractTestCase { 13 | 14 | @Override 15 | public void doTest() { 16 | Colors colors = new Colors(engine); 17 | 18 | HSLColor hsl = colors.hsl("red"); 19 | assertEquals(0.0, hsl.h(), 1e-6); 20 | assertEquals(1.0, hsl.s(), 1e-6); 21 | assertEquals(0.5, hsl.l(), 1e-6); 22 | hsl = hsl.darker(); 23 | assertTrue(hsl.h() < 255); 24 | hsl = hsl.brighter(); 25 | assertEquals(0.0, hsl.h(), TOLERANCE); 26 | RGBColor rgb = hsl.rgb(); 27 | assertEquals(255, rgb.r()); 28 | assertEquals(0, rgb.g()); 29 | assertEquals(0, rgb.b()); 30 | 31 | HSLColor hsl2 = colors.hsl(120, 1, 0.5); 32 | System.out.println(hsl2.toHexaString()); 33 | 34 | HSLColor hsl3 = colors.hsl(rgb); 35 | assertEquals(0.0, hsl3.h(), 1e-6); 36 | assertEquals(1.0, hsl3.s(), 1e-6); 37 | assertEquals(0.5, hsl3.l(), 1e-6); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/color/RgbColorTest.java: -------------------------------------------------------------------------------- 1 | 2 | package org.treez.javafxd3.d3.color; 3 | 4 | import org.treez.javafxd3.d3.color.Colors; 5 | import org.treez.javafxd3.d3.color.HSLColor; 6 | import org.treez.javafxd3.d3.color.RGBColor; 7 | 8 | import org.treez.javafxd3.d3.AbstractTestCase; 9 | 10 | /** 11 | * Tests the class RgbColor 12 | */ 13 | public class RgbColorTest extends AbstractTestCase { 14 | 15 | @Override 16 | public void doTest() { 17 | 18 | Colors colors = new Colors(engine); 19 | 20 | RGBColor rgb = colors.rgb("#ff0000"); 21 | assertEquals(255, rgb.r()); 22 | assertEquals(0, rgb.g()); 23 | assertEquals(0, rgb.b()); 24 | rgb = rgb.darker(); 25 | assertTrue(rgb.r() < 255); 26 | rgb = rgb.brighter().brighter(); 27 | assertEquals(255, rgb.r()); 28 | HSLColor hsl = rgb.hsl(); 29 | System.out.println(hsl.h()); 30 | System.out.println(hsl.s()); 31 | System.out.println(hsl.l()); 32 | 33 | RGBColor rgb2 = colors.rgb(0, 0, 255); 34 | assertEquals(0, rgb2.r()); 35 | assertEquals(0, rgb2.g()); 36 | assertEquals(255, rgb2.b()); 37 | System.out.println(rgb2.toHexaString()); 38 | 39 | RGBColor rgb3 = colors.rgb(hsl); 40 | assertEquals(255, rgb3.r()); 41 | assertEquals(0, rgb3.g()); 42 | assertEquals(0, rgb3.b()); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/core/FormatTest.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.core; 2 | 3 | import org.treez.javafxd3.d3.AbstractTestCase; 4 | 5 | /** 6 | * Thest the format method of the d3 wrapper 7 | * 8 | */ 9 | public class FormatTest extends AbstractTestCase { 10 | 11 | @Override 12 | public void doTest() { 13 | 14 | d3.format("%s").format(456.34); 15 | assertEquals(123.12,d3.round(123.1234,2),1e-6); 16 | 17 | assertEquals("This is a 'quoted' string, yes \\? And the dots, like \\. are counted as \\{literals\\}", 18 | d3.requote("This is a 'quoted' string, yes ? And the dots, like . are counted as {literals}")); 19 | 20 | Prefix prefix = d3.formatPrefix(123456.12345, 1); 21 | assertEquals("k",prefix.symbol()); 22 | 23 | assertEquals(1000.0,prefix.scale(1000000),1e-6); 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/core/RandomTest.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.core; 2 | 3 | import org.treez.javafxd3.d3.core.Random; 4 | 5 | import org.treez.javafxd3.d3.AbstractTestCase; 6 | 7 | /** 8 | * Tests the class Random 9 | */ 10 | public class RandomTest extends AbstractTestCase { 11 | 12 | @Override 13 | public void doTest() { 14 | Random random = new Random(engine); 15 | 16 | random.normal().generate(); 17 | random.normal(1000).generate(); 18 | random.normal(1000, 40).generate(); 19 | 20 | random.logNormal().generate(); 21 | random.logNormal(1000).generate(); 22 | random.logNormal(1000, 40).generate(); 23 | 24 | random.irwinHall(456).generate(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/dsv/person/Person.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.dsv.person; 2 | 3 | public class Person { 4 | 5 | //#region ATTRIBUTES 6 | 7 | private final String name; 8 | 9 | private final int age; 10 | 11 | //#ene region 12 | 13 | //#region CONSTRUCTORS 14 | 15 | public Person(final String name, final int age) { 16 | this.name = name; 17 | this.age = age; 18 | } 19 | 20 | //#end region 21 | 22 | //#region METHODS 23 | 24 | @Override 25 | public String toString() { 26 | return "Person [name=" + name + ", age=" + age + "]"; 27 | } 28 | 29 | //#end region 30 | 31 | //#region ACCESSORS 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public int getAge() { 38 | return age; 39 | } 40 | 41 | //#end region 42 | 43 | } 44 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/dsv/person/PersonAccessor.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.dsv.person; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.dsv.DsvObjectAccessor; 6 | import org.treez.javafxd3.d3.dsv.DsvRow; 7 | 8 | public class PersonAccessor implements DsvObjectAccessor { 9 | 10 | private JsEngine engine; 11 | 12 | public PersonAccessor(JsEngine engine) { 13 | this.engine = engine; 14 | } 15 | 16 | @Override 17 | public Person apply(final Object row, final int index) { 18 | 19 | 20 | DsvRow csvRow = ConversionUtil.convertObjectTo(row, DsvRow.class, engine); 21 | 22 | String name = csvRow.get("Name").asString(); 23 | int age = csvRow.get("Age").asInt(); 24 | 25 | return new Person(name,age ); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/dsv/person/PersonArrayAccessor.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.dsv.person; 2 | 3 | import org.treez.javafxd3.d3.arrays.Array; 4 | import org.treez.javafxd3.d3.core.ConversionUtil; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.dsv.DsvArrayAccessor; 7 | 8 | public class PersonArrayAccessor implements DsvArrayAccessor { 9 | 10 | private JsEngine engine; 11 | 12 | public PersonArrayAccessor(JsEngine engine){ 13 | this.engine = engine; 14 | } 15 | 16 | @Override 17 | public Person parse(final Object rowArray, final int index) { 18 | 19 | @SuppressWarnings("unchecked") 20 | Array row = (Array) ConversionUtil.convertObjectTo(rowArray, Array.class, engine); 21 | String age = row.get(1, String.class); 22 | return new Person(row.get(0, String.class), Integer.parseInt(age)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/dsv/person/PersonCallback.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.dsv.person; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNull; 5 | 6 | import java.util.List; 7 | 8 | import org.treez.javafxd3.d3.arrays.Array; 9 | import org.treez.javafxd3.d3.core.ConversionUtil; 10 | import org.treez.javafxd3.d3.core.JsEngine; 11 | import org.treez.javafxd3.d3.dsv.DsvCallback; 12 | 13 | public class PersonCallback implements DsvCallback { 14 | 15 | private JsEngine engine; 16 | 17 | public PersonCallback(JsEngine engine) { 18 | this.engine = engine; 19 | } 20 | 21 | @Override 22 | public void get(final Object error, final Object personArray) { 23 | 24 | 25 | @SuppressWarnings("unchecked") 26 | Array values = (Array) ConversionUtil.convertObjectTo(personArray, Array.class, engine); 27 | List valueList = values.asList(Person.class); 28 | 29 | assertNull(error); 30 | assertEquals(5, valueList.size()); 31 | Person jane = valueList.get(2); 32 | assertEquals("Jane", jane.getName()); 33 | assertEquals(15, jane.getAge()); 34 | } 35 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/dsv/person/PersonRowCallback.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.dsv.person; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNull; 5 | 6 | import java.util.List; 7 | 8 | import org.treez.javafxd3.d3.arrays.Array; 9 | import org.treez.javafxd3.d3.core.ConversionUtil; 10 | import org.treez.javafxd3.d3.core.JsEngine; 11 | import org.treez.javafxd3.d3.dsv.DsvCallback; 12 | import org.treez.javafxd3.d3.dsv.DsvRow; 13 | 14 | public class PersonRowCallback implements DsvCallback { 15 | 16 | private JsEngine engine; 17 | 18 | public PersonRowCallback(JsEngine engine) { 19 | this.engine = engine; 20 | } 21 | 22 | @Override 23 | public void get(final Object error, final Object dsvRowArray) { 24 | 25 | 26 | @SuppressWarnings("unchecked") 27 | Array values = (Array) ConversionUtil.convertObjectTo(dsvRowArray, Array.class, engine); 28 | List valueList = values.asList(DsvRow.class); 29 | 30 | assertNull(error); 31 | assertEquals(5, valueList.size()); 32 | DsvRow jane = valueList.get(2); 33 | assertEquals("Jane", jane.get("Name").asString()); 34 | assertEquals(15, (int) jane.get("Age").asInt()); 35 | } 36 | } -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/functions/DataFunctionTest.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions; 2 | 3 | import org.treez.javafxd3.d3.AbstractTestCase; 4 | import org.treez.javafxd3.d3.functions.DataFunction; 5 | 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class DataFunctionTest extends AbstractTestCase { 9 | 10 | @Override 11 | public void doTest() { 12 | 13 | JsObject d3Obj = d3.getJsObject(); 14 | 15 | DataFunction datumFunction = new StringDataFunction(); 16 | 17 | d3Obj.setMember("temp__function", datumFunction); 18 | 19 | int index = 3; 20 | String command = "d3.temp__function.apply(undefined, d3, "+index+")"; 21 | Object result = d3.eval(command); 22 | assertEquals(result, "" + index); 23 | 24 | } 25 | 26 | public class StringDataFunction implements DataFunction { 27 | @Override 28 | public String apply(Object context, Object d, int index) { 29 | String contextType = context.getClass().getName(); 30 | System.out.println("DataFunctionTest context type:" + contextType); 31 | 32 | String datumType = d.getClass().getName(); 33 | System.out.println("DataFunctionTest datum type:" + datumType); 34 | 35 | String value = "" + index; 36 | return value; 37 | } 38 | } 39 | 40 | 41 | 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/scales/LogScaleTestDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.scales; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | 7 | /** 8 | * Used by the LogScaleTest 9 | * 10 | */ 11 | public class LogScaleTestDataFunction implements DataFunction { 12 | 13 | //#region ATTRIBUTES 14 | 15 | JsEngine engine; 16 | 17 | //#end region 18 | 19 | 20 | //#region CONSTRUCTORS 21 | 22 | LogScaleTestDataFunction(JsEngine engine){ 23 | this.engine = engine; 24 | } 25 | 26 | //#end region 27 | 28 | //#region METHODS 29 | 30 | @Override 31 | public String apply(Object context, Object d, int index) { 32 | 33 | System.out.println("Inside LogScaleTestDataFunction"); 34 | 35 | return "blah"; 36 | } 37 | 38 | //#end regions 39 | 40 | } 41 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/scales/TimeScaleTest.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.scales; 2 | 3 | import org.treez.javafxd3.d3.AbstractTestCase; 4 | 5 | 6 | public class TimeScaleTest extends AbstractTestCase { 7 | 8 | 9 | 10 | @Override 11 | public void doTest() { 12 | 13 | /* 14 | Object[] domain = d3.time().scale().domain(); 15 | assertEquals(2, domain.length); 16 | System.out.println(domain[0].asJsDate()); 17 | System.out.println(domain[1].asJsDate()); 18 | Object[] range = d3.time().scale().range(new Integer[]{0, 5}).range(); 19 | 20 | */ 21 | 22 | // nice and count 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/AssertOneChildDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.treez.javafxd3.d3.core.ConversionUtil; 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | import org.treez.javafxd3.d3.functions.DataFunction; 8 | import org.treez.javafxd3.d3.wrapper.Element; 9 | 10 | 11 | 12 | public class AssertOneChildDataFunction implements DataFunction { 13 | 14 | private JsEngine engine; 15 | 16 | public AssertOneChildDataFunction(JsEngine engine){ 17 | this.engine = engine; 18 | } 19 | 20 | @Override 21 | public Void apply(final Object context, final Object d, final int index) { 22 | 23 | Element element = ConversionUtil.convertObjectTo(context, Element.class, engine); 24 | 25 | assertEquals(1, element.getChildCount()); 26 | return null; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/GetSpanDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | import org.treez.javafxd3.d3.wrapper.Element; 7 | 8 | public class GetSpanDataFunction implements DataFunction { 9 | 10 | private JsEngine engine; 11 | 12 | public GetSpanDataFunction(JsEngine engine) { 13 | this.engine = engine; 14 | } 15 | 16 | @Override 17 | public Element[] apply(final Object context, final Object d, final int index) { 18 | 19 | Element element = ConversionUtil.convertObjectTo(context, Element.class, engine); 20 | Element[] spans = element.getElementsByTagName("span"); 21 | return spans; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/comparator/ValueComparator.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.comparator; 2 | 3 | 4 | 5 | import java.util.Comparator; 6 | 7 | import org.treez.javafxd3.d3.core.ConversionUtil; 8 | import org.treez.javafxd3.d3.core.JsEngine; 9 | import org.treez.javafxd3.d3.core.Value; 10 | 11 | /** 12 | * A datum function that asserts that the datum equals an increasing 13 | * counting index, starting with 1. 14 | * 15 | */ 16 | public class ValueComparator implements Comparator { 17 | 18 | //#region ATTRIBUTES 19 | 20 | private JsEngine engine; 21 | 22 | //#end region 23 | 24 | //#region CONSTRUCTORS 25 | 26 | public ValueComparator(JsEngine engine){ 27 | this.engine = engine; 28 | } 29 | 30 | 31 | @Override 32 | public int compare(Object o1, Object o2) { 33 | 34 | Value firstValue = ConversionUtil.convertObjectTo(o1, Value.class, engine); 35 | Value secondValue = ConversionUtil.convertObjectTo(o2, Value.class, engine); 36 | 37 | Integer d1 = firstValue. as(); 38 | Integer d2 = secondValue. as(); 39 | System.out.println("sorting: " + d1 + " " + d2); 40 | 41 | return d1.compareTo(d2); 42 | } 43 | 44 | //#end region 45 | 46 | //#region METHODS 47 | 48 | 49 | 50 | //#end region 51 | 52 | } 53 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/AssertCounterDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.treez.javafxd3.d3.core.ConversionUtil; 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | import org.treez.javafxd3.d3.functions.DataFunction; 8 | 9 | 10 | 11 | /** 12 | * A datum function that asserts that the datum equals an increasing 13 | * counting index, starting with 1. 14 | * 15 | */ 16 | public class AssertCounterDataFunction implements DataFunction { 17 | 18 | //#region ATTRIBUTES 19 | 20 | private JsEngine engine; 21 | 22 | private int counter = 1; 23 | 24 | 25 | //#end region 26 | 27 | //#region CONSTRUCTORS 28 | 29 | /** 30 | * @param engine 31 | */ 32 | public AssertCounterDataFunction(JsEngine engine){ 33 | this.engine=engine; 34 | } 35 | 36 | //#end region 37 | 38 | //#region METHODS 39 | 40 | @Override 41 | public Void apply(Object context, Object datum, int index) { 42 | int value = ConversionUtil.convertObjectTo(datum, Integer.class, engine); 43 | assertEquals(counter, value); 44 | counter++; 45 | return null; 46 | } 47 | 48 | //#end region 49 | 50 | } 51 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/AssertNullStringDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import static org.junit.Assert.assertNull; 4 | 5 | import org.treez.javafxd3.d3.core.ConversionUtil; 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | import org.treez.javafxd3.d3.functions.DataFunction; 8 | 9 | /** 10 | * A datum function that asserts that the datum equals an increasing counting 11 | * index, starting with 1. 12 | * 13 | */ 14 | public class AssertNullStringDataFunction implements DataFunction { 15 | 16 | //#region ATTRIBUTES 17 | 18 | private JsEngine engine; 19 | 20 | //#end region 21 | 22 | //#region CONSTRUCTORS 23 | 24 | /** 25 | * @param engine 26 | */ 27 | public AssertNullStringDataFunction(JsEngine engine) { 28 | this.engine = engine; 29 | } 30 | 31 | //#end region 32 | 33 | //#region METHODS 34 | 35 | @Override 36 | public Void apply(Object context, Object datum, int index) { 37 | Integer value = ConversionUtil.convertObjectTo(datum, Integer.class, engine); 38 | assertNull(value); 39 | return null; 40 | 41 | } 42 | 43 | //#end region 44 | 45 | } 46 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/AssertOddEvenDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.treez.javafxd3.d3.core.ConversionUtil; 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | import org.treez.javafxd3.d3.functions.DataFunction; 8 | 9 | public class AssertOddEvenDataFunction implements DataFunction { 10 | 11 | //#region ATTRIBUTES 12 | 13 | private static final double DELTA = 1e-6; 14 | 15 | private JsEngine engine; 16 | private double oddValue; 17 | private double evenValue; 18 | 19 | //#end region 20 | 21 | //#region CONSTRUCTORS 22 | 23 | public AssertOddEvenDataFunction(JsEngine engine, double oddValue, double evenValue) { 24 | this.engine = engine; 25 | this.oddValue = oddValue; 26 | this.evenValue = evenValue; 27 | } 28 | 29 | //#end region 30 | 31 | //#region METHODS 32 | 33 | @Override 34 | public Void apply(Object context, Object datum, int index) { 35 | double value = ConversionUtil.convertObjectTo(datum, Double.class, engine); 36 | Double expected = ((index % 2) == 0) ? oddValue : evenValue; 37 | assertEquals(expected, value, DELTA); 38 | return null; 39 | } 40 | 41 | //#end region 42 | 43 | } 44 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/AssertStringDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.treez.javafxd3.d3.core.ConversionUtil; 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | import org.treez.javafxd3.d3.functions.DataFunction; 8 | 9 | 10 | 11 | /** 12 | * A datum function that asserts that the datum equals an increasing 13 | * counting index, starting with 1. 14 | * 15 | */ 16 | public class AssertStringDataFunction implements DataFunction { 17 | 18 | //#region ATTRIBUTES 19 | 20 | private JsEngine engine; 21 | 22 | private String expectedValue; 23 | 24 | //#end region 25 | 26 | 27 | //#region CONSTRUCTORS 28 | 29 | /** 30 | * @param engine 31 | */ 32 | public AssertStringDataFunction(JsEngine engine, String expectedValue){ 33 | this.engine=engine; 34 | this.expectedValue=expectedValue; 35 | } 36 | 37 | //#end region 38 | 39 | //#region METHODS 40 | 41 | @Override 42 | public Void apply(Object context, Object datum, int index) { 43 | String value = ConversionUtil.convertObjectTo(datum, String.class, engine); 44 | assertEquals(expectedValue, value); 45 | return null; 46 | } 47 | 48 | //#end region 49 | 50 | } 51 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/IntegerArrayDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.core.Value; 6 | import org.treez.javafxd3.d3.functions.DataFunction; 7 | 8 | /** 9 | * A datum function that returns the datum as integer array 10 | * 11 | */ 12 | public class IntegerArrayDataFunction implements DataFunction { 13 | 14 | //#region ATTRIBUTES 15 | 16 | private JsEngine engine; 17 | 18 | //#end region 19 | 20 | //#region CONSTRUCTORS 21 | 22 | /** 23 | * @param engine 24 | */ 25 | public IntegerArrayDataFunction(JsEngine engine){ 26 | this.engine=engine; 27 | } 28 | 29 | //#end region 30 | 31 | //#region METHODS 32 | 33 | @Override 34 | public Integer[] apply(Object context, Object datum, int index) { 35 | Value value = ConversionUtil.convertObjectTo(datum, Value.class, engine); 36 | int[] intArray = value.as(); 37 | Integer[] integerObjectArray = convertToIntegerArray(intArray); 38 | return integerObjectArray; 39 | } 40 | 41 | private Integer[] convertToIntegerArray(int[] intArray) { 42 | Integer[] integerArray = new Integer[intArray.length]; 43 | int i = 0; 44 | for (int intValue : intArray) { 45 | integerArray[i++] = Integer.valueOf(intValue); 46 | } 47 | return integerArray; 48 | } 49 | 50 | //#end region 51 | 52 | } 53 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/ObjectArrayDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.core.Value; 6 | import org.treez.javafxd3.d3.functions.DataFunction; 7 | 8 | /** 9 | * A datum function that returns the datum as object array 10 | * 11 | */ 12 | public class ObjectArrayDataFunction implements DataFunction { 13 | 14 | //#region ATTRIBUTES 15 | 16 | private JsEngine engine; 17 | 18 | //#end region 19 | 20 | //#region CONSTRUCTORS 21 | 22 | /** 23 | * @param engine 24 | */ 25 | public ObjectArrayDataFunction(JsEngine engine){ 26 | this.engine=engine; 27 | } 28 | 29 | //#end region 30 | 31 | //#region METHODS 32 | 33 | @Override 34 | public Object[] apply(Object context, Object datum, int index) { 35 | 36 | Value value = ConversionUtil.convertObjectTo(datum, Value.class, engine); 37 | 38 | System.out.println(context + " " + value.asString() + " " + index); 39 | Object[] as = value.as(); 40 | System.out.println(as); 41 | return as; 42 | 43 | } 44 | 45 | //#end region 46 | 47 | } 48 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/OddEvenDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | 6 | 7 | 8 | public class OddEvenDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private double oddValue; 13 | private double evenValue; 14 | 15 | 16 | //#end region 17 | 18 | //#region CONSTRUCTORS 19 | 20 | public OddEvenDataFunction( double oddValue, double evenValue){ 21 | this.oddValue = oddValue; 22 | this.evenValue = evenValue; 23 | } 24 | 25 | //#end region 26 | 27 | //#region METHODS 28 | 29 | @Override 30 | public Double apply(Object context, Object datum, int index) { 31 | Double result = (index % 2) == 0 ? oddValue : evenValue; 32 | return result; 33 | } 34 | 35 | //#end region 36 | 37 | } 38 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/OddEvenElementDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | import org.treez.javafxd3.d3.wrapper.Element; 7 | 8 | public class OddEvenElementDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine; 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public OddEvenElementDataFunction(JsEngine engine){ 19 | this.engine = engine; 20 | } 21 | 22 | //#end region 23 | 24 | //#region METHODS 25 | 26 | @Override 27 | public Element apply(Object context, Object datum, int index) { 28 | Element element = ConversionUtil.convertObjectTo(context, Element.class, engine); 29 | Element result = (index % 2) == 0 ? element : null; 30 | return result; 31 | } 32 | 33 | //#end region 34 | 35 | } 36 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/PrefixPlusIndexDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | 6 | public class PrefixPlusIndexDataFunction implements DataFunction { 7 | 8 | //#region ATTRIBUTES 9 | 10 | private String prefix; 11 | 12 | //#end region 13 | 14 | //#region CONSTRUCTORS 15 | 16 | public PrefixPlusIndexDataFunction(String prefix){ 17 | this.prefix=prefix; 18 | } 19 | 20 | //#end region 21 | 22 | //#region METHODS 23 | 24 | @Override 25 | public String apply(Object context, Object datum, int index) { 26 | return prefix + index; 27 | } 28 | 29 | //#end region 30 | 31 | } 32 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/StringBuilderFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | import org.treez.javafxd3.d3.wrapper.Element; 7 | 8 | /** 9 | * A DataFunction that appends strings to a wrapped StringBuilder 10 | */ 11 | public class StringBuilderFunction implements DataFunction { 12 | 13 | //#region ATTRIBUTES 14 | 15 | private StringBuilder stringBuilder; 16 | private JsEngine engine; 17 | 18 | //#end region 19 | 20 | //#region CONSTRUCTORS 21 | 22 | public StringBuilderFunction(JsEngine engine, StringBuilder stringBuilder){ 23 | this.engine = engine; 24 | this.stringBuilder = stringBuilder; 25 | } 26 | //#end region 27 | 28 | //#region METHODS 29 | 30 | @Override 31 | public Void apply(Object context, Object datum, int index) { 32 | Element element = ConversionUtil.convertObjectTo(context, Element.class, engine); 33 | stringBuilder.append(element.getText()); 34 | return null; 35 | } 36 | 37 | //#end region 38 | 39 | } 40 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/datafunction/StringDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.datafunction; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | 7 | public class StringDataFunction implements DataFunction { 8 | 9 | //#region ATTRIBUTES 10 | 11 | private JsEngine engine; 12 | 13 | //#end region 14 | 15 | //#region CONSTRUCTORS 16 | 17 | public StringDataFunction(JsEngine engine){ 18 | this.engine=engine; 19 | } 20 | 21 | //#end region 22 | 23 | //#region METHODS 24 | 25 | @Override 26 | public String apply(Object context, Object datum, int index) { 27 | String stringValue = ConversionUtil.convertObjectTo(datum, String.class, engine); 28 | return stringValue; 29 | } 30 | 31 | //#end region 32 | 33 | } 34 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/keyfunction/IntegerKeyFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.keyfunction; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.KeyFunction; 6 | 7 | public class IntegerKeyFunction implements KeyFunction { 8 | 9 | //#region ATTRIBUTES 10 | 11 | private JsEngine engine; 12 | 13 | //#end region 14 | 15 | //#region CONSTRUCTORS 16 | 17 | public IntegerKeyFunction(JsEngine engine){ 18 | this.engine=engine; 19 | } 20 | 21 | //#end region 22 | 23 | //#region METHODS 24 | 25 | @Override 26 | public Integer call(final Object context, final Object newDataArray, final Object datum, final int index) { 27 | 28 | Integer value = ConversionUtil.convertObjectTo(datum, Integer.class, engine); 29 | return value; 30 | } 31 | 32 | //#end region 33 | 34 | } 35 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/selection/keyfunction/SelectionData2KeyFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.selection.keyfunction; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.core.Value; 6 | import org.treez.javafxd3.d3.functions.KeyFunction; 7 | import org.treez.javafxd3.d3.wrapper.Element; 8 | 9 | public class SelectionData2KeyFunction implements KeyFunction { 10 | 11 | private JsEngine engine; 12 | 13 | public SelectionData2KeyFunction(JsEngine engine){ 14 | this.engine = engine; 15 | } 16 | 17 | @Override 18 | public Integer call(final Object context, final Object newDataArray, final Object datum, final int index) { 19 | 20 | Element element = ConversionUtil.convertObjectTo(context, Element.class, engine); 21 | Value value = ConversionUtil.convertObjectTo(datum, Value.class, engine); 22 | 23 | if (context != null) { 24 | 25 | System.out.println("looping through existing element div with value " + value.asInt() + " blah: " + element.getAttribute("blah") 26 | + " index: " + index); 27 | return value.asInt(); 28 | } else { 29 | System.out.println("looping through new given data value " + value.asInt() + " blah: " + value.asInt() + " index: " + index); 30 | return value.asInt(); 31 | } 32 | 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/ChordDef.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg; 2 | 3 | public class ChordDef { 4 | 5 | //#region ATTRIBUTES 6 | 7 | public double start; 8 | public double end; 9 | public double radius; 10 | 11 | //#end region 12 | 13 | //#region CONSTRUCTORS 14 | 15 | public ChordDef(double start, double end, double radius) { 16 | super(); 17 | this.start = start; 18 | this.end = end; 19 | this.radius = radius; 20 | } 21 | 22 | //#end region 23 | 24 | } 25 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/ChordTest.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg; 2 | 3 | import org.treez.javafxd3.d3.AbstractTestCase; 4 | import org.treez.javafxd3.d3.svg.datafunction.ChordRadiusDataFunction; 5 | import org.treez.javafxd3.d3.svg.datafunction.ChordSourceDataFunction; 6 | import org.treez.javafxd3.d3.svg.datafunction.ChordStartAngleDataFunction; 7 | import org.treez.javafxd3.d3.svg.datafunction.ChordTargetDataFunction; 8 | 9 | 10 | @SuppressWarnings("javadoc") 11 | public class ChordTest extends AbstractTestCase { 12 | 13 | @Override 14 | public void doTest() { 15 | 16 | 17 | 18 | Chord chord = d3.svg().chord(); 19 | 20 | // constants 21 | chord.startAngle(5); 22 | chord.endAngle(5); 23 | chord.radius(6); 24 | 25 | chord.source(new ChordSourceDataFunction()); 26 | chord.target(new ChordTargetDataFunction()); 27 | 28 | // chord 29 | chord.startAngle(new ChordStartAngleDataFunction(engine)) // 30 | .endAngle(new ChordStartAngleDataFunction(engine)) // 31 | .radius(new ChordRadiusDataFunction(engine)); 32 | 33 | chord.generate(new Double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/SymbolTest.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg; 2 | 3 | 4 | import org.treez.javafxd3.d3.svg.Symbol; 5 | import org.treez.javafxd3.d3.svg.datafunction.IndexDataFunction; 6 | import org.treez.javafxd3.d3.AbstractTestCase; 7 | import org.treez.javafxd3.d3.functions.data.ConstantDataFunction; 8 | 9 | 10 | public class SymbolTest extends AbstractTestCase { 11 | 12 | 13 | 14 | @Override 15 | public void doTest() { 16 | 17 | 18 | 19 | // check the symbol types match the Symbol.Type.values 20 | String[] types = symbolTypes(); 21 | for (int i = 0; i < types.length; i++) { 22 | String type = types[i]; 23 | System.out.println("SYMBOL TYPE: " + type); 24 | SymbolType typeEnum = SymbolType.valueOf(type.toUpperCase().replace('-', 25 | '_')); 26 | if (typeEnum == null) { 27 | fail("the symbol type " + type + " is not implemented"); 28 | } 29 | } 30 | 31 | Symbol symbol = d3.svg().symbol(); 32 | symbol.size(32); 33 | symbol.size(new IndexDataFunction()); 34 | 35 | symbol.type(SymbolType.CIRCLE); 36 | symbol.type(new ConstantDataFunction(SymbolType.CIRCLE)); 37 | } 38 | 39 | /** 40 | * Return the list of supported symbol types, which match the 41 | * {@link Type#values()}. 42 | *

43 | * 44 | * @return the list of supported symbol types 45 | */ 46 | public String[] symbolTypes(){ 47 | 48 | 49 | Object result = d3.eval("this.svg.symbolTypes"); 50 | String resultString = result.toString(); 51 | String[] symbolTypes = resultString.split(","); 52 | return symbolTypes; 53 | 54 | }; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/ChordEndAngleDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | import org.treez.javafxd3.d3.svg.ChordDef; 7 | 8 | public class ChordEndAngleDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine; 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public ChordEndAngleDataFunction(JsEngine engine){ 19 | this.engine=engine; 20 | } 21 | 22 | //#end region 23 | 24 | //#region METHODS 25 | 26 | @Override 27 | public Double apply(Object context, Object datum, int index) { 28 | 29 | ChordDef chordDef = ConversionUtil.convertObjectTo(datum, ChordDef.class, engine); 30 | Double end = chordDef.end; 31 | System.out.println("end: " + end); 32 | return end; 33 | } 34 | 35 | //#end region 36 | 37 | } 38 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/ChordRadiusDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | import org.treez.javafxd3.d3.svg.ChordDef; 7 | 8 | public class ChordRadiusDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine; 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public ChordRadiusDataFunction(JsEngine engine){ 19 | this.engine=engine; 20 | 21 | } 22 | 23 | //#end region 24 | 25 | //#region METHODS 26 | 27 | @Override 28 | public Double apply(Object context, Object datum, int index) { 29 | 30 | ChordDef chordDef = ConversionUtil.convertObjectTo(datum, ChordDef.class, engine); 31 | Double radius = chordDef.radius; 32 | System.out.println("radius: " + radius); 33 | return radius; 34 | } 35 | 36 | //#end region 37 | 38 | } 39 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/ChordSourceDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.svg.ChordDef; 5 | 6 | 7 | public class ChordSourceDataFunction implements DataFunction { 8 | 9 | 10 | //#region CONSTRUCTORS 11 | 12 | public ChordSourceDataFunction(){ 13 | } 14 | 15 | //#end region 16 | 17 | //#region METHODS 18 | 19 | @Override 20 | public ChordDef apply(Object context, Object d, int index) { 21 | System.out.println("source: " + d); 22 | return new ChordDef(index * 5, index * 5, index * 5); 23 | } 24 | 25 | //#end region 26 | 27 | } 28 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/ChordStartAngleDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | import org.treez.javafxd3.d3.svg.ChordDef; 7 | 8 | public class ChordStartAngleDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine; 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public ChordStartAngleDataFunction(JsEngine engine){ 19 | this.engine=engine; 20 | } 21 | 22 | //#end region 23 | 24 | //#region METHODS 25 | 26 | @Override 27 | public Double apply(Object context, Object datum, int index) { 28 | 29 | ChordDef chordDef = ConversionUtil.convertObjectTo(datum, ChordDef.class, engine); 30 | Double start = chordDef.start; 31 | System.out.println("start: " + start); 32 | return start; 33 | } 34 | 35 | //#end region 36 | 37 | } 38 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/ChordTargetDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.svg.ChordDef; 5 | 6 | 7 | public class ChordTargetDataFunction implements DataFunction { 8 | 9 | 10 | //#region CONSTRUCTORS 11 | 12 | /** 13 | * @param engine 14 | */ 15 | public ChordTargetDataFunction(){ 16 | } 17 | 18 | //#end region 19 | 20 | //#region METHODS 21 | 22 | @Override 23 | public ChordDef apply(Object context, Object d, int index) { 24 | System.out.println("target: " + d); 25 | return new ChordDef(index * 5, index * 5, index * 5); 26 | } 27 | 28 | //#end region 29 | 30 | } 31 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/IndexDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | 6 | public class IndexDataFunction implements DataFunction { 7 | 8 | //#region CONSTRUCTORS 9 | 10 | public IndexDataFunction() { 11 | 12 | } 13 | 14 | //#end region 15 | 16 | //#region METHODS 17 | 18 | @Override 19 | public Integer apply(Object context, Object datum, int index) { 20 | return index; 21 | } 22 | 23 | //#end region 24 | 25 | } 26 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/IndexFactorDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | 6 | public class IndexFactorDataFunction implements DataFunction { 7 | 8 | //#region ATTRIBUTES 9 | 10 | Double factor; 11 | 12 | //#end region 13 | 14 | //#region CONSTRUCTORS 15 | 16 | public IndexFactorDataFunction(Double factor) { 17 | this.factor = factor; 18 | } 19 | 20 | //#end region 21 | 22 | //#region METHODS 23 | 24 | @Override 25 | public Double apply(Object context, Object datum, int index) { 26 | Double result = index * factor; 27 | return result; 28 | } 29 | 30 | //#end region 31 | 32 | } 33 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/IndexSwitchDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | 6 | public class IndexSwitchDataFunction implements DataFunction { 7 | 8 | 9 | //#region CONSTRUCTORS 10 | 11 | public IndexSwitchDataFunction(){ 12 | } 13 | 14 | //#end region 15 | 16 | //#region METHODS 17 | 18 | @Override 19 | public Boolean apply(Object context, Object datum, int index) { 20 | return index == 1 ? false : true; 21 | } 22 | 23 | //#end region 24 | 25 | } 26 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/TickTestDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import org.treez.javafxd3.d3.core.Value; 6 | import org.treez.javafxd3.d3.functions.DataFunction; 7 | 8 | import org.treez.javafxd3.d3.core.JsEngine; 9 | 10 | 11 | public class TickTestDataFunction implements DataFunction { 12 | 13 | //#region ATTRIBUTES 14 | 15 | private JsEngine engine; 16 | 17 | private final StringBuffer stringBuffer; 18 | 19 | //#end region 20 | 21 | //#region CONSTRUCTORS 22 | 23 | public TickTestDataFunction(JsEngine engine, final StringBuffer stringBuffer){ 24 | this.engine=engine; 25 | this.stringBuffer = stringBuffer; 26 | } 27 | 28 | //#end region 29 | 30 | //#region METHODS 31 | 32 | @Override 33 | public String apply(Object context, Object datum, int index) { 34 | 35 | Value value = Value.create(engine, datum); 36 | System.out.println("INDEX " + index + " " + value.as()); 37 | assertTrue(index >= 0 && index < 4); 38 | stringBuffer.append("x"); 39 | if (index % 2 == 0) { 40 | return ""; 41 | } 42 | return "" + index; 43 | } 44 | 45 | //#end region 46 | 47 | } 48 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/XCaptureDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import java.util.List; 4 | 5 | import org.treez.javafxd3.d3.coords.Coords; 6 | import org.treez.javafxd3.d3.core.ConversionUtil; 7 | import org.treez.javafxd3.d3.core.JsEngine; 8 | import org.treez.javafxd3.d3.functions.DataFunction; 9 | 10 | 11 | public class XCaptureDataFunction implements DataFunction { 12 | 13 | //#region ATTRIBUTES 14 | 15 | private JsEngine engine; 16 | 17 | private List xList; 18 | 19 | //#end region 20 | 21 | //#region CONSTRUCTORS 22 | 23 | public XCaptureDataFunction(JsEngine engine, List xList){ 24 | this.engine=engine; 25 | this.xList = xList; 26 | } 27 | 28 | //#end region 29 | 30 | //#region METHODS 31 | 32 | @Override 33 | public Double apply(Object context, Object datum, int index) { 34 | 35 | Coords coords = ConversionUtil.convertObjectTo(datum, Coords.class, engine); 36 | Double x = coords.x(); 37 | xList.add(x); 38 | return x; 39 | } 40 | 41 | //#end region 42 | 43 | } 44 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/XDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import org.treez.javafxd3.d3.coords.Coords; 4 | import org.treez.javafxd3.d3.core.ConversionUtil; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.functions.DataFunction; 7 | 8 | 9 | public class XDataFunction implements DataFunction { 10 | 11 | //#region ATTRIBUTES 12 | 13 | private JsEngine engine; 14 | 15 | //#end region 16 | 17 | //#region CONSTRUCTORS 18 | 19 | public XDataFunction(JsEngine engine){ 20 | this.engine=engine; 21 | 22 | } 23 | 24 | //#end region 25 | 26 | //#region METHODS 27 | 28 | @Override 29 | public Double apply(Object context, Object datum, int index) { 30 | 31 | Coords coords = ConversionUtil.convertObjectTo(datum, Coords.class, engine); 32 | Double x = coords.x(); 33 | return x; 34 | } 35 | 36 | //#end region 37 | 38 | } 39 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/YCaptureDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import java.util.List; 4 | 5 | import org.treez.javafxd3.d3.coords.Coords; 6 | import org.treez.javafxd3.d3.core.ConversionUtil; 7 | import org.treez.javafxd3.d3.core.JsEngine; 8 | import org.treez.javafxd3.d3.functions.DataFunction; 9 | 10 | 11 | public class YCaptureDataFunction implements DataFunction { 12 | 13 | //#region ATTRIBUTES 14 | 15 | private JsEngine engine; 16 | 17 | private List yList; 18 | 19 | //#end region 20 | 21 | //#region CONSTRUCTORS 22 | 23 | public YCaptureDataFunction(JsEngine engine, List yList){ 24 | this.engine=engine; 25 | this.yList = yList; 26 | } 27 | 28 | //#end region 29 | 30 | //#region METHODS 31 | 32 | @Override 33 | public Double apply(Object context, Object datum, int index) { 34 | 35 | Coords coords = ConversionUtil.convertObjectTo(datum, Coords.class, engine); 36 | Double y = coords.y(); 37 | yList.add(y); 38 | return y; 39 | } 40 | 41 | //#end region 42 | 43 | } 44 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/YCoordsCounterDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import java.util.List; 4 | 5 | import org.treez.javafxd3.d3.coords.Coords; 6 | import org.treez.javafxd3.d3.core.ConversionUtil; 7 | import org.treez.javafxd3.d3.core.JsEngine; 8 | import org.treez.javafxd3.d3.functions.DataFunction; 9 | 10 | public class YCoordsCounterDataFunction implements DataFunction { 11 | 12 | //#region ATTRIBUTES 13 | 14 | private JsEngine engine; 15 | 16 | private List yList; 17 | 18 | private Coords counter; 19 | 20 | 21 | 22 | //#end region 23 | 24 | //#region CONSTRUCTORS 25 | 26 | public YCoordsCounterDataFunction(JsEngine engine, List yList, Coords counter){ 27 | this.engine=engine; 28 | this.yList = yList; 29 | this.counter = counter; 30 | } 31 | 32 | //#end region 33 | 34 | //#region METHODS 35 | 36 | @Override 37 | public Double apply(Object context, Object datum, int index) { 38 | 39 | counter.y(counter.y() + 1); 40 | 41 | Coords coords = ConversionUtil.convertObjectTo(datum, Coords.class, engine); 42 | Double y = coords.y(); 43 | yList.add(y); 44 | return y; 45 | } 46 | 47 | //#end region 48 | 49 | } 50 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/svg/datafunction/YDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.svg.datafunction; 2 | 3 | import org.treez.javafxd3.d3.coords.Coords; 4 | import org.treez.javafxd3.d3.core.ConversionUtil; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.functions.DataFunction; 7 | 8 | 9 | public class YDataFunction implements DataFunction { 10 | 11 | //#region ATTRIBUTES 12 | 13 | private JsEngine engine; 14 | 15 | //#end region 16 | 17 | //#region CONSTRUCTORS 18 | 19 | public YDataFunction(JsEngine engine){ 20 | this.engine=engine; 21 | 22 | } 23 | 24 | //#end region 25 | 26 | //#region METHODS 27 | 28 | @Override 29 | public Double apply(Object context, Object datum, int index) { 30 | 31 | Coords coords = ConversionUtil.convertObjectTo(datum, Coords.class, engine); 32 | Double y = coords.y(); 33 | return y; 34 | } 35 | 36 | //#end region 37 | 38 | } 39 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/transition/function/CustomEasingFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.transition.function; 2 | 3 | import org.treez.javafxd3.d3.ease.EasingFunction; 4 | 5 | public class CustomEasingFunction implements EasingFunction { 6 | 7 | @Override 8 | public double ease(final double t) { 9 | return t; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/transition/function/InterpolatorTweenFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.transition.function; 2 | 3 | import org.treez.javafxd3.d3.interpolators.Interpolator; 4 | import org.treez.javafxd3.d3.tweens.TweenFunction; 5 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 6 | 7 | import org.treez.javafxd3.d3.core.JsEngine; 8 | import org.treez.javafxd3.d3.core.JsObject; 9 | 10 | public class InterpolatorTweenFunction extends JavaScriptObject implements TweenFunction{ 11 | 12 | public InterpolatorTweenFunction(JsEngine engine){ 13 | super(engine); 14 | } 15 | 16 | 17 | @Override 18 | public JsObject apply(final Object context, 19 | final Object datum, final int index, final Object value) { 20 | 21 | Interpolator interpolator = new TestCallableInterpolator(engine); 22 | return interpolator.asJsFunction(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/java/org/treez/javafxd3/d3/transition/function/TestCallableInterpolator.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.transition.function; 2 | 3 | import org.treez.javafxd3.d3.interpolators.CallableInterpolator; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | 7 | public class TestCallableInterpolator extends CallableInterpolator{ 8 | 9 | public TestCallableInterpolator(JsEngine engine){ 10 | super(engine); 11 | } 12 | 13 | @Override 14 | public String interpolate(Object t) { 15 | return (int) ((Double)t * 10) + "px"; 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /javafx-d3-demo/src/test/resources/javafxd3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefaneidelloth/javafx-d3/5c72e247a9c7a5f9bb4d6a520b1d811f7ca11c60/javafx-d3-demo/src/test/resources/javafxd3.png -------------------------------------------------------------------------------- /javafx-d3/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | -------------------------------------------------------------------------------- /javafx-d3/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | javafx-d3 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.ManifestBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.pde.SchemaBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.m2e.core.maven2Nature 31 | org.eclipse.jdt.core.javanature 32 | org.eclipse.pde.PluginNature 33 | 34 | 35 | -------------------------------------------------------------------------------- /javafx-d3/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding8= 3 | -------------------------------------------------------------------------------- /javafx-d3/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | formatter_profile=_javafx-d3 3 | formatter_settings_version=12 4 | -------------------------------------------------------------------------------- /javafx-d3/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /javafx-d3/.settings/org.moreunit.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.moreunit.preferences.version=2 3 | org.moreunit.unitsourcefolder=javafx-d3\:main/java\:javafx-d3-demo\:src/test/java 4 | org.moreunit.useprojectsettings=true 5 | -------------------------------------------------------------------------------- /javafx-d3/META-INF/log4j.properties: -------------------------------------------------------------------------------- 1 | # set output level and appender (for now, console only) 2 | log4j.rootLogger=DEBUG, ConsoleAppender, TreezConsoleAppender 3 | 4 | # configure console appender 5 | log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender 6 | log4j.appender.ConsoleAppender.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.ConsoleAppender.layout.ConversionPattern=%-6r [%t] %-5p %c{1} %x: %m%n 8 | 9 | # configure treez console appender 10 | log4j.appender.TreezConsoleAppender=org.treez.core.console.TreezConsoleAppender 11 | log4j.appender.TreezConsoleAppender.layout=org.apache.log4j.PatternLayout 12 | log4j.appender.TreezConsoleAppender.layout.ConversionPattern=%-6r [%t] %-5p %c{1} %x: %m%n 13 | 14 | # configure rolling file appender (not used at the moment) 15 | log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender 16 | log4j.appender.rollingFile.File=Logfile.log 17 | log4j.appender.rollingFile.MaxFileSize=5MB 18 | log4j.appender.rollingFile.MaxBackupIndex=0 19 | log4j.appender.rollingFile.layout = org.apache.log4j.PatternLayout 20 | log4j.appender.rollingFile.layout.ConversionPattern=%-6r [%t] %-5p %c{1} %x: %m%n -------------------------------------------------------------------------------- /javafx-d3/build.properties: -------------------------------------------------------------------------------- 1 | source.. = main/java/,\ 2 | main/resources/,\ 3 | test/java/,\ 4 | test/resources/ 5 | bin.includes = META-INF/,\ 6 | . 7 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/arrays/foreach/CompleteForEachCallbackWrapper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.arrays.foreach; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | 5 | public class CompleteForEachCallbackWrapper implements ForEachCallback{ 6 | 7 | private JsEngine engine; 8 | 9 | private ForEachCallback wrappedCallback; 10 | 11 | public CompleteForEachCallbackWrapper(JsEngine engine, ForEachCallback wrappedCallback){ 12 | this.wrappedCallback=wrappedCallback; 13 | this.engine = engine; 14 | } 15 | 16 | @Override 17 | public T forEach(Object context, Object element, int index, Object array){ 18 | Object jsContext = engine.toJsObjectIfNotSimpleType(context); 19 | Object jsElement = engine.toJsObjectIfNotSimpleType(element); 20 | return wrappedCallback.forEach(jsContext, jsElement, index, array); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/arrays/foreach/ForEachCallback.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.arrays.foreach; 2 | 3 | public interface ForEachCallback { 4 | 5 | /** 6 | * Executed for each element of the array with an assigned value. 7 | *

8 | * If a thisArg parameter is provided to Array#forEach(ForEachCallback, Object), it will be used as the thisArg parameter for 9 | * each callback invocation. 10 | *

11 | * If thisArg is undefined or null, the this value within the function depends on whether the function is in strict mode or not (passed 12 | * value if in strict mode, global object if in non-strict mode). 13 | * 14 | * https:US/docs/JavaScript/Reference/Global_Objects/Array/forEach 15 | * 16 | */ 17 | R forEach(Object context, Object element, int index, Object array); 18 | } 19 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/arrays/foreach/ForEachCallbackWrapper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.arrays.foreach; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.functions.data.wrapper.PlainDataFunction; 5 | 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | 8 | /** 9 | * Wraps a ForEachCallback that only needs the element as argument. The type of 10 | * the element is converted to the required type A 11 | */ 12 | public class ForEachCallbackWrapper implements ForEachCallback { 13 | 14 | //#region ATTRIBUTES 15 | 16 | private JsEngine engine = null; 17 | 18 | private PlainDataFunction plainDataFunction = null; 19 | 20 | private Class plainClass = null; 21 | 22 | //#end region 23 | 24 | //#region CONSTRUCTORS 25 | 26 | public ForEachCallbackWrapper(Class classOfArgument, JsEngine engine, 27 | PlainDataFunction plainDataFunction) { 28 | this.engine = engine; 29 | this.plainDataFunction = plainDataFunction; 30 | this.plainClass = classOfArgument; 31 | } 32 | 33 | //#end region 34 | 35 | //#region METHODS 36 | 37 | @Override 38 | public R forEach(Object context, Object arrayElement, int index, Object array) { 39 | A data = ConversionUtil.convertObjectTo(arrayElement, plainClass, engine); 40 | if (data != null) { 41 | return plainDataFunction.apply(data); 42 | } else { 43 | return null; 44 | } 45 | } 46 | 47 | //#end region 48 | 49 | } 50 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/arrays/foreach/ForEachObjectDelegate.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.arrays.foreach; 2 | 3 | public interface ForEachObjectDelegate { 4 | 5 | public void process(Object element); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/arrays/foreach/ForEachObjectDelegateWrapper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.arrays.foreach; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | 5 | /** 6 | * Wraps a ForEachObjectDelegate in a named class so that it can 7 | * be used in the JavaScript world (that would not work with anonymous functions directly). 8 | */ 9 | public class ForEachObjectDelegateWrapper implements ForEachObjectDelegate{ 10 | 11 | private JsEngine engine; 12 | 13 | private ForEachObjectDelegate wrappedDelegate; 14 | 15 | public ForEachObjectDelegateWrapper(JsEngine engine, ForEachObjectDelegate wrappedDelegate){ 16 | this.engine = engine; 17 | this.wrappedDelegate=wrappedDelegate; 18 | } 19 | 20 | @Override 21 | public void process(Object element) { 22 | Object jsElement = engine.toJsObjectIfNotSimpleType(element); 23 | wrappedDelegate.process(jsElement); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/arrays/foreach/NumericForEachCallback.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.arrays.foreach; 2 | 3 | /** 4 | * Same as {@link ForEachCallback} but ensure the result is treated as a numeric 5 | * double. 6 | */ 7 | public interface NumericForEachCallback extends ForEachCallback { 8 | 9 | /** 10 | * Executed for each element of the array with an assigned value. 11 | *

12 | * If a thisArg parameter is provided to 13 | * Array#forEach(NumericForEachCallback, Object), it will be used as the 14 | * thisArg parameter for each callback invocation. 15 | *

16 | * If thisArg is undefined or null, the this value within the function 17 | * depends on whether the function is in strict mode or not (passed value if 18 | * in strict mode, global object if in non-strict mode). 19 | * 20 | * https:US/docs/JavaScript/Reference/Global_Objects/Array/forEach 21 | * 22 | * @param thisArg 23 | * @param element 24 | * @param index 25 | * @param array 26 | * @return 27 | */ 28 | Double forEach(Object thisArg, Object element, int index, Object array); 29 | } 30 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/behaviour/Behavior.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.behaviour; 2 | 3 | import org.treez.javafxd3.d3.core.Selection; 4 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 5 | 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | import org.treez.javafxd3.d3.core.JsObject; 8 | 9 | /** 10 | * The behaviour module. 11 | */ 12 | public class Behavior extends JavaScriptObject { 13 | 14 | //#region CONSTRUCTORS 15 | 16 | /** 17 | * @param engine 18 | * @param wrappedJsObject 19 | */ 20 | public Behavior(JsEngine engine, JsObject wrappedJsObject) { 21 | super(engine); 22 | setJsObject(wrappedJsObject); 23 | } 24 | 25 | //#end region 26 | 27 | //#region METHODS 28 | 29 | /** 30 | * Create a new {@link Drag} behavior, that you will configure and apply to 31 | * a {@link Selection}. 32 | * 33 | * @return the drag behaviour 34 | */ 35 | public Drag drag() { 36 | JsObject result = call("drag"); 37 | return new Drag(engine, result); 38 | } 39 | 40 | /** 41 | * Create a new {@link Zoom} behavior, that you will configure and apply to 42 | * a {@link Selection}. 43 | * 44 | * @return the zoom behaviour 45 | */ 46 | public Zoom zoom() { 47 | JsObject result = call("zoom"); 48 | return new Zoom(engine, result); 49 | } 50 | 51 | //#end region 52 | 53 | } 54 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/core/JsEngine.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.core; 2 | 3 | public interface JsEngine { 4 | 5 | /** 6 | * Executes a script in the context of the current page. 7 | * @return execution result, converted to a Java object using the following 8 | * rules: 9 | *

18 | */ 19 | Object executeScript(String script); 20 | 21 | /** 22 | * Wraps a java script object argument if it is not 23 | * a simple type 24 | * @return 25 | */ 26 | Object toJsObjectIfNotSimpleType(Object argument); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/core/Prefix.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.core; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | /** 9 | * A SI Prefix, as 10 | * returned by D3#formatPrefix() 11 | *

12 | * Example: 13 | * 14 | * {@code 15 | * var prefix = d3.formatPrefix(1.21e9); 16 | * 17 | * console.log(prefix.symbol); 18 | * 19 | * console.log(prefix.scale(1.21e9)); // 1.21 20 | * } 21 | *

22 | */ 23 | public class Prefix extends JavaScriptObject { 24 | 25 | //#region CONSTRUCTORS 26 | 27 | /** 28 | * @param engine 29 | * @param wrappedJsObject 30 | */ 31 | public Prefix(JsEngine engine, JsObject wrappedJsObject) { 32 | super(engine); 33 | setJsObject(wrappedJsObject); 34 | 35 | } 36 | 37 | //#end region 38 | 39 | //#region METHODS 40 | 41 | /** 42 | * Returns the prefix symbol, such as "M" for millions. 43 | *

44 | * 45 | * @return the prefix symbol 46 | */ 47 | public String symbol() { 48 | String result = getMemberForString("symbol"); 49 | return result; 50 | } 51 | 52 | /** 53 | * Convert the number to the appropriate prefixed scale. 54 | *

55 | * 56 | * @param input 57 | * the number to convert 58 | * @return the converted number 59 | */ 60 | public double scale(double input) { 61 | Double result = callForDouble("scale", input); 62 | return result; 63 | } 64 | 65 | //#end region 66 | } 67 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/dsv/DsvArrayAccessor.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.dsv; 2 | 3 | /** 4 | * This accessor function is invoked for each row in a DSV file, being passed 5 | * the current row and index as two arguments. The return value of the function 6 | * replaces the element in the returned array of rows; if the function returns 7 | * null, the row is stripped from the returned array of rows. In effect, the 8 | * accessor is similar to applying a map and filter operator to the returned 9 | * rows. The accessor function is used by parse to convert each row to an object 10 | * with named attributes. 11 | * 12 | * 13 | * 14 | * @param 15 | * the type of the parsed DSV line 16 | * 17 | * @see Dsv#parseRows(String) 18 | */ 19 | public interface DsvArrayAccessor { 20 | 21 | /** 22 | * An accessor function may invoked for each row in a DSV file, being passed 23 | * the current row and index as two arguments. The return value of the 24 | * function replaces the element in the returned array of rows; if the 25 | * function returns null, the row is stripped from the returned array of 26 | * rows. In effect, the accessor is similar to applying a map and filter 27 | * operator to the returned rows. The accessor function is used by parse to 28 | * convert each row to an object with named attributes. 29 | * 30 | * @param row the current row as an array 31 | * @param index the index of the current row 32 | * @return 33 | */ 34 | T parse(Object rowArray, int index); 35 | } 36 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/dsv/DsvCallback.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.dsv; 2 | 3 | /** 4 | * When the DSV data is available, the specified callback will be invoked with 5 | * the parsed row array as the argument. If an error occurs, the callback function 6 | * will instead be invoked with null. 7 | * 8 | * 9 | * 10 | * the type of the parsed DSV line (if no accessor is provided, the 11 | * type will be {@link DsvRow}) 12 | * @param 13 | */ 14 | public interface DsvCallback { 15 | 16 | /** 17 | * When the CSV data is available, the specified callback will be invoked 18 | * with the parsed rows as the argument. If an error occurs, the callback 19 | * function will instead be invoked with null. 20 | * 21 | * @param error the error, if any occurs. 22 | * @param data 23 | * @param rows the rows values, or null if an error occurs. 24 | */ 25 | void get(Object error, Object rowsArray); 26 | } 27 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/dsv/DsvObjectAccessor.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.dsv; 2 | 3 | import org.treez.javafxd3.d3.functions.ObjectAccessor; 4 | 5 | /** 6 | * An accessor function which is passed to Dsv#parse(String, DsObjectAccessor)}. 7 | * 8 | * @param 9 | */ 10 | public interface DsvObjectAccessor extends ObjectAccessor {} 11 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/dsv/DsvRow.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.dsv; 2 | 3 | import org.treez.javafxd3.d3.core.Value; 4 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 5 | 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | import org.treez.javafxd3.d3.core.JsObject; 8 | 9 | /** 10 | * Each row of a CSV or TSV file is represented by a DsvRow 11 | */ 12 | public class DsvRow extends JavaScriptObject { 13 | 14 | //#region CONSTRUCTORS 15 | 16 | public DsvRow(JsEngine engine, JsObject wrappedJsObject) { 17 | super(engine); 18 | setJsObject(wrappedJsObject); 19 | } 20 | 21 | //#end region 22 | 23 | //#region METHODS 24 | 25 | /** 26 | * Generic method to get the value of a named field. 27 | * 28 | * @param field 29 | * @return 30 | */ 31 | public Value get(String field) { 32 | 33 | String command = "this['" + field + "']"; 34 | Object resultObj = eval(command); 35 | Value entryValue = Value.create(engine, resultObj); 36 | return entryValue; 37 | } 38 | 39 | 40 | //#end region 41 | } 42 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/ease/EasingFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.ease; 2 | 3 | /** 4 | * An easing function takes the current parameterized time value t in the domain [0,1], 5 | * and maps it to another value in a similar range; it is typically used to set Transition#ease(). 6 | *

7 | * Built-in {@link EasingFunction}s may be created using {@link Easing} factory. 8 | *

9 | * 10 | * 11 | */ 12 | public interface EasingFunction { 13 | /** 14 | * Given a parametric time t in the range [0,1], returns the eased time. 15 | *

16 | * The returned value is typically in the range [0,1] as well, but may 17 | * extend slightly beyond this range for certain easing functions, such as 18 | * "elastic". 19 | *

20 | * 21 | * @param t 22 | * the parametric time 23 | * @return the eased time 24 | */ 25 | double ease(double t); 26 | } 27 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/ease/JavascriptEasingFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.ease; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | /** 9 | * JSNI easing functions. 10 | */ 11 | public class JavascriptEasingFunction extends JavaScriptObject implements EasingFunction { 12 | 13 | //#region CONSTRUCTORS 14 | 15 | /** 16 | * @param engine 17 | * @param wrappedJsObject 18 | */ 19 | public JavascriptEasingFunction(JsEngine engine, JsObject wrappedJsObject) { 20 | super(engine); 21 | setJsObject(wrappedJsObject); 22 | 23 | } 24 | 25 | //#end region 26 | 27 | //#region METHODS 28 | 29 | 30 | @Override 31 | public double ease(double t){ 32 | String command = "this("+t+")"; 33 | Object resultObj = eval(command); 34 | String stringValue = resultObj.toString(); 35 | Double result = Double.parseDouble(stringValue); 36 | return result; 37 | } 38 | 39 | //#end region 40 | } 41 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/ease/Mode.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.ease; 2 | 3 | /** 4 | * 5 | * 6 | */ 7 | public enum Mode { 8 | 9 | //#region VALUES 10 | 11 | /** 12 | * The identity function 13 | */ 14 | IN("in"), 15 | 16 | /** 17 | * reverses the easing direction [1,0] 18 | */ 19 | OUT("out"), 20 | 21 | /** 22 | * copies and mirrors the easing function from [0,.5] and [.5,1]. 23 | */ 24 | IN_OUT("in-out"), 25 | 26 | /** 27 | * copies and mirrors the easing function from [1,.5] and [.5,0]. 28 | */ 29 | OUT_IN("out-in"); 30 | 31 | //#end region 32 | 33 | //#region ATTRIBUTES 34 | 35 | private String value; 36 | 37 | //#end region 38 | 39 | //#region CONSTRUCTORS 40 | 41 | private Mode(final String value) { 42 | this.value = value; 43 | } 44 | 45 | //#end region 46 | 47 | //#region ACCESSORS 48 | 49 | /** 50 | * @return 51 | */ 52 | public String getValue() { 53 | return value; 54 | } 55 | 56 | //#end region 57 | } 58 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/event/D3Event.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.event; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.core.JsObject; 5 | 6 | /** 7 | * 8 | * @param 9 | * 10 | */ 11 | public class D3Event extends Event { 12 | 13 | //#region CONSTRUCTORS 14 | 15 | /** 16 | * Constructor 17 | * @param engine 18 | * @param wrappedJsObject 19 | */ 20 | public D3Event(JsEngine engine, JsObject wrappedJsObject) { 21 | super(engine, wrappedJsObject); 22 | } 23 | 24 | //#end region 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/event/Event.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.event; 2 | 3 | import org.treez.javafxd3.d3.core.Selection; 4 | import org.treez.javafxd3.d3.functions.JsFunction; 5 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 6 | 7 | import org.treez.javafxd3.d3.core.JsEngine; 8 | import org.treez.javafxd3.d3.core.JsObject; 9 | 10 | public class Event extends JavaScriptObject implements JsFunction { 11 | 12 | 13 | //#region CONSTRUCTORS 14 | 15 | public Event(JsEngine engine, JsObject wrappedJsObject) { 16 | super(engine, wrappedJsObject); 17 | } 18 | 19 | //#end region 20 | 21 | //#region ACCESSORS 22 | 23 | /** 24 | * @return 25 | */ 26 | public Selection getEventTarget(){ 27 | JsObject result = getMember("target"); 28 | return new Selection(engine, result); 29 | } 30 | 31 | public Event sourceEvent() { 32 | JsObject result = call("this.sourceEvent"); 33 | return new Event(engine, result); 34 | } 35 | 36 | public void stopPropagation() { 37 | call("this.stopPropagation()"); 38 | } 39 | 40 | //#end region 41 | 42 | } -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/DataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions; 2 | 3 | import org.treez.javafxd3.d3.core.Selection; 4 | 5 | 6 | /** 7 | * A function taking an element and the index of the element in the selection, 8 | * returning a value of type T. 9 | *

10 | * This function must be passed to mutator functions of {@link Selection} when you 11 | * know that nodes are not bound to any data. 12 | * 13 | * 14 | * @param 15 | * @param 16 | * 17 | */ 18 | public interface DataFunction { 19 | 20 | /** 21 | * Apply the function for the given context at the specified index 22 | * of the {@link Selection} mapped to the given datum. 23 | *

24 | * Note that if no datum is mapped to the element, Datum#isUndefined() will return true. 25 | * 26 | * @param context 27 | * the current element, may be irrelevant or null in some context. 28 | * @param datum 29 | * the datum 30 | * @param index 31 | * the index of the context element in the selection 32 | * @return a result to be applied 33 | */ 34 | public R apply(Object context, Object datum, int index); 35 | } 36 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/DragFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions; 2 | 3 | public interface DragFunction { 4 | 5 | void handleDragStart(Object context, Object d, int index); 6 | 7 | void handleDrag(Object context, Object d, int index); 8 | 9 | void handleDragEnd(Object context, Object d, int index); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/JsFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions; 2 | 3 | /** 4 | * A marker interface. JavaScriptObjects that implement this 5 | * interface wrap a JsObject that is a java script function. 6 | *

7 | */ 8 | public interface JsFunction { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/MouseClickFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions; 2 | 3 | /** 4 | * A function that handles mouse clicks. 5 | * 6 | * @param 7 | * @param 8 | * 9 | */ 10 | public interface MouseClickFunction { 11 | 12 | public void handleMouseClick(Object context); 13 | } 14 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/ObjectAccessor.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions; 2 | 3 | import org.treez.javafxd3.d3.dsv.DsvRow; 4 | 5 | public interface ObjectAccessor { 6 | 7 | /** 8 | * The accessor function which transform a {@link DsvRow} in an other type 9 | * T. 10 | * 11 | * @param row 12 | * the current DSV row 13 | * @param index 14 | * index of the current DSV row 15 | * @return 16 | */ 17 | R apply(A data, int index); 18 | } 19 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/TimerFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions; 2 | 3 | /** 4 | * A function to be used with D3 timer(). 5 | *

6 | */ 7 | public interface TimerFunction { 8 | 9 | /** 10 | * Return true to stop the timer, false to continue. 11 | * 12 | * @return true to stop the timer, false to continue. 13 | */ 14 | boolean execute(); 15 | } 16 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/accessor/DsvObjectAccessorWrapper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.accessor; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.dsv.DsvObjectAccessor; 6 | import org.treez.javafxd3.d3.functions.data.wrapper.PlainDataFunction; 7 | 8 | public class DsvObjectAccessorWrapper implements DsvObjectAccessor { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine = null; 13 | 14 | private PlainDataFunction plainDataFunction = null; 15 | 16 | private Class plainClass = null; 17 | 18 | //#end region 19 | 20 | //#region CONSTRUCTORS 21 | 22 | public DsvObjectAccessorWrapper(Class classOfArgument, JsEngine engine, 23 | PlainDataFunction plainDataFunction) { 24 | this.engine = engine; 25 | this.plainDataFunction = plainDataFunction; 26 | this.plainClass = classOfArgument; 27 | } 28 | 29 | //#end region 30 | 31 | //#region METHODS 32 | 33 | @Override 34 | public R apply(Object datum, int index) { 35 | A convertedDatum = ConversionUtil.convertObjectTo(datum, plainClass, engine); 36 | return plainDataFunction.apply(convertedDatum); 37 | } 38 | 39 | //#end region 40 | 41 | } 42 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/callback/DsvCallbackWrapper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.callback; 2 | 3 | import org.treez.javafxd3.d3.arrays.Array; 4 | import org.treez.javafxd3.d3.core.ConversionUtil; 5 | import org.treez.javafxd3.d3.dsv.DsvCallback; 6 | 7 | import org.treez.javafxd3.d3.core.JsEngine; 8 | 9 | public class DsvCallbackWrapper implements DsvCallback { 10 | 11 | //#region ATTRIBUTES 12 | 13 | private JsEngine engine = null; 14 | 15 | private PlainCallback> plainCallback = null; 16 | 17 | //#end region 18 | 19 | //#region CONSTRUCTORS 20 | 21 | public DsvCallbackWrapper(JsEngine engine, PlainCallback> plainCallback) { 22 | this.engine = engine; 23 | this.plainCallback = plainCallback; 24 | } 25 | 26 | //#end region 27 | 28 | //#region METHODS 29 | 30 | @Override 31 | public void get(Object error, Object dataArrayObj) { 32 | 33 | @SuppressWarnings("unchecked") 34 | Array dataArray = (Array) ConversionUtil.convertObjectTo(dataArrayObj, Array.class, engine); 35 | plainCallback.call(dataArray); 36 | } 37 | 38 | //#end region 39 | 40 | } 41 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/callback/PlainCallback.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.callback; 2 | 3 | public interface PlainCallback { 4 | 5 | void call(A argument); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/AppendDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 5 | 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class AppendDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsObject jsObjectToAppend; 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public AppendDataFunction(JavaScriptObject objectToAppend) { 19 | this.jsObjectToAppend = objectToAppend.getJsObject(); 20 | } 21 | 22 | //#end region 23 | 24 | //#region METHODS 25 | 26 | @Override 27 | public Object apply(Object context, Object datum, int index) { 28 | return jsObjectToAppend.unwrap(); 29 | } 30 | 31 | //#end region 32 | 33 | } 34 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/ColorScaleLevelDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.QuantitativeScale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class ColorScaleLevelDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine; 13 | 14 | private QuantitativeScale scale; 15 | 16 | //#end region 17 | 18 | //#region CONSTRUCTORS 19 | 20 | public ColorScaleLevelDataFunction(JsEngine engine, QuantitativeScale scale){ 21 | this.engine = engine; 22 | this.scale = scale; 23 | } 24 | 25 | //#end region 26 | 27 | //#region METHODS 28 | 29 | @Override 30 | public String apply(Object context, Object datum, int index) { 31 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 32 | Object levelObject = jsObject.eval("this.level"); 33 | String scaledValue = scale.applyForString(levelObject.toString()); 34 | return scaledValue; 35 | } 36 | 37 | //#end region 38 | 39 | } 40 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/ConstantDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | /** 6 | * A DataFunction that returns a constant value 7 | */ 8 | public class ConstantDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | T constantValue; 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public ConstantDataFunction(T constantValue){ 19 | this.constantValue = constantValue; 20 | } 21 | //#end region 22 | 23 | //#region METHODS 24 | 25 | @Override 26 | public T apply(Object context, Object datum, int index) { 27 | return constantValue; 28 | } 29 | 30 | //#end region 31 | 32 | } 33 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/CountDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data; 2 | 3 | import org.treez.javafxd3.d3.core.Selection; 4 | import org.treez.javafxd3.d3.functions.DataFunction; 5 | 6 | /** 7 | * A {@link DataFunction} that counts something, mainly used as a debugging purpose 8 | * in {@link Selection#each(DataFunction)} method. 9 | *

10 | * You may override the #takeIntoAccount(Element, Datum, int) to change when the count is incremented. 11 | * 12 | * 13 | * 14 | */ 15 | public class CountDataFunction implements DataFunction { 16 | 17 | //#region ATTRIBUTES 18 | 19 | private int count = 0; 20 | 21 | //#end region 22 | 23 | //#region CONSTRUCTORS 24 | 25 | public CountDataFunction(){} 26 | 27 | //#end region 28 | 29 | //#region METHODS 30 | 31 | @Override 32 | public Void apply(final Object context, final Object d, final int index) { 33 | if (takeIntoAccount(context, d, index)) { 34 | count++; 35 | } 36 | return null; 37 | } 38 | 39 | /** 40 | * Return true by default. 41 | * 42 | * @param context 43 | * @param d 44 | * @param index 45 | * @return true to increment the count, false otherwise. 46 | */ 47 | private boolean takeIntoAccount(final Object context, final Object d, final int index) { 48 | return true; 49 | } 50 | 51 | /** 52 | * @return 53 | */ 54 | public int getCount() { 55 | return count; 56 | } 57 | 58 | /** 59 | * @return 60 | */ 61 | public CountDataFunction reset() { 62 | count = 0; 63 | return this; 64 | } 65 | 66 | //#end region 67 | } -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/DelegatingDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | import org.treez.javafxd3.d3.core.JsObject; 6 | 7 | /** 8 | * A DataFunction that delegates the apply call to a JsObject 9 | */ 10 | public class DelegatingDataFunction implements DataFunction { 11 | 12 | //#region ATTRIBUTES 13 | 14 | JsObject wrappedJsObject; 15 | 16 | //#end region 17 | 18 | //#region CONSTRUCTORS 19 | 20 | public DelegatingDataFunction(JsObject wrappedJsObject){ 21 | this.wrappedJsObject = wrappedJsObject; 22 | } 23 | //#end region 24 | 25 | //#region METHODS 26 | 27 | @Override 28 | public Object apply(Object context, Object datum, int index) { 29 | Object applyResult = wrappedJsObject.call("apply", datum, index); 30 | return applyResult; 31 | } 32 | 33 | //#end region 34 | 35 | } 36 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/EvenIndexDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | /** 6 | * A DataFunction that returns true if the index is even 7 | */ 8 | public class EvenIndexDataFunction implements DataFunction { 9 | 10 | 11 | //#region METHODS 12 | 13 | @Override 14 | public Boolean apply(Object context, Object datum, int index) { 15 | boolean isEven = (index % 2) == 0; 16 | return isEven; 17 | } 18 | 19 | //#end region 20 | 21 | } 22 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/array/FirstDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.array; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.core.JsObject; 6 | 7 | /** 8 | * A datum function that returns the first array element as double 9 | * 10 | */ 11 | public class FirstDataFunction implements DataFunction { 12 | 13 | //#region ATTRIBUTES 14 | 15 | private JsEngine engine; 16 | 17 | //#end region 18 | 19 | //#region CONSTRUCTORS 20 | 21 | 22 | public FirstDataFunction(JsEngine engine){ 23 | this.engine=engine; 24 | } 25 | 26 | //#end region 27 | 28 | //#region METHODS 29 | 30 | @Override 31 | public Double apply(Object context, Object datum, int index) { 32 | 33 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 34 | Object value = jsObject.eval("this[0]"); 35 | Double first = Double.parseDouble(value.toString()); 36 | return first; 37 | } 38 | 39 | //#end region 40 | 41 | } 42 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/array/SecondDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.array; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.core.JsObject; 6 | 7 | /** 8 | * A datum function that returns the second array element as double 9 | * 10 | */ 11 | public class SecondDataFunction implements DataFunction { 12 | 13 | private JsEngine engine; 14 | 15 | //#region CONSTRUCTORS 16 | 17 | public SecondDataFunction(JsEngine engine){ 18 | this.engine=engine; 19 | } 20 | 21 | //#end region 22 | 23 | //#region METHODS 24 | 25 | @Override 26 | public Double apply(Object context, Object datum, int index) { 27 | 28 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 29 | Object value = jsObject.eval("this[1]"); 30 | Double second = Double.parseDouble(value.toString()); 31 | return second; 32 | } 33 | 34 | //#end region 35 | 36 | } 37 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/attribute/AttributeDoubleDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.attribute; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.core.JsObject; 6 | 7 | public class AttributeDoubleDataFunction implements DataFunction { 8 | 9 | //#region ATTRIBTES 10 | 11 | private JsEngine engine; 12 | 13 | private String attributeName; 14 | 15 | //#end region 16 | 17 | //#region CONSTRUCTORS 18 | 19 | public AttributeDoubleDataFunction(JsEngine engine, String attributeName){ 20 | this.engine=engine; 21 | this.attributeName = attributeName; 22 | } 23 | 24 | //#end region 25 | 26 | //#region METHODS 27 | 28 | @Override 29 | public Double apply(Object context, Object datum, int index) { 30 | 31 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 32 | Object object = jsObject.eval("this." + attributeName); 33 | Double value = Double.parseDouble(object.toString()); 34 | return value; 35 | } 36 | 37 | //#end region 38 | 39 | } 40 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/attribute/AttributeStringDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.attribute; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.core.JsObject; 6 | 7 | public class AttributeStringDataFunction implements DataFunction { 8 | 9 | 10 | //#region ATTRIBTES 11 | 12 | private JsEngine engine; 13 | 14 | private String attributeName; 15 | 16 | //#end region 17 | 18 | //#region CONSTRUCTORS 19 | 20 | public AttributeStringDataFunction(JsEngine engine,String attributeName){ 21 | this.engine = engine; 22 | this.attributeName=attributeName; 23 | } 24 | 25 | //#end region 26 | 27 | //#region METHODS 28 | 29 | @Override 30 | public String apply(Object context, Object datum, int index) { 31 | 32 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 33 | Object key = jsObject.eval("this." + attributeName); 34 | return key.toString(); 35 | } 36 | 37 | //#end region 38 | 39 | } 40 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleFirstDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.Scale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | /** 9 | * A datum function that extracts the first value from a data array 10 | * and scales it with the given scale 11 | * 12 | */ 13 | public class AxisScaleFirstDataFunction implements DataFunction { 14 | 15 | //#region ATTRIBUTES 16 | 17 | private JsEngine engine; 18 | 19 | private Scale scale; 20 | 21 | //#end region 22 | 23 | //#region CONSTRUCTORS 24 | 25 | /** 26 | * @param engine 27 | */ 28 | public AxisScaleFirstDataFunction(JsEngine engine,Scale scale){ 29 | this.engine = engine; 30 | this.scale = scale; 31 | } 32 | 33 | //#end region 34 | 35 | //#region METHODS 36 | 37 | @Override 38 | public Double apply(Object context, Object datum, int index) { 39 | 40 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 41 | Object firstValueObj = jsObject.eval("this[0]"); 42 | Double scaledValue = scale.applyForDouble(firstValueObj.toString()); 43 | return scaledValue; 44 | } 45 | 46 | //#end region 47 | 48 | } 49 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleInversedFirstDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.QuantitativeScale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | 9 | public class AxisScaleInversedFirstDataFunction implements DataFunction { 10 | 11 | //#region ATTRIBUTES 12 | 13 | private JsEngine engine; 14 | 15 | private QuantitativeScale scale; 16 | 17 | private double maxValue; 18 | 19 | //#end region 20 | 21 | //#region CONSTRUCTORS 22 | 23 | public AxisScaleInversedFirstDataFunction(JsEngine engine, QuantitativeScale scale, double maxValue){ 24 | this.engine=engine; 25 | this.scale = scale; 26 | this.maxValue = maxValue; 27 | } 28 | 29 | //#end region 30 | 31 | //#region METHODS 32 | 33 | @Override 34 | public Double apply(Object context, Object datum, int index) { 35 | 36 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 37 | 38 | Object secondValueObj = jsObject.eval("this[0]"); 39 | Double secondValue = Double.parseDouble(secondValueObj.toString()); 40 | 41 | Double scaledValue = scale.apply(secondValue).asDouble(); 42 | double inversedValue = maxValue-scaledValue; 43 | return inversedValue; 44 | } 45 | 46 | //#end region 47 | 48 | } 49 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleInversedSecondDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.QuantitativeScale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | 9 | public class AxisScaleInversedSecondDataFunction implements DataFunction { 10 | 11 | //#region ATTRIBUTES 12 | 13 | private JsEngine engine; 14 | 15 | private QuantitativeScale scale; 16 | 17 | private double maxValue; 18 | 19 | //#end region 20 | 21 | //#region CONSTRUCTORS 22 | 23 | /** 24 | * @param engine 25 | */ 26 | public AxisScaleInversedSecondDataFunction(JsEngine engine, QuantitativeScale scale, double maxValue){ 27 | this.engine = engine; 28 | this.scale = scale; 29 | this.maxValue = maxValue; 30 | } 31 | 32 | //#end region 33 | 34 | //#region METHODS 35 | 36 | @Override 37 | public Double apply(Object context, Object datum, int index) { 38 | 39 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 40 | 41 | Object secondValueObj = jsObject.eval("this[1]"); 42 | Double secondValue = Double.parseDouble(secondValueObj.toString()); 43 | 44 | Double scaledValue = scale.apply(secondValue).asDouble(); 45 | double inversedValue = maxValue-scaledValue; 46 | return inversedValue; 47 | } 48 | 49 | //#end region 50 | 51 | } 52 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleInversedSizeDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.Scale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class AxisScaleInversedSizeDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine; 13 | 14 | private Scale scale; 15 | 16 | //#end region 17 | 18 | //#region CONSTRUCTORS 19 | 20 | /** 21 | * @param engine 22 | */ 23 | public AxisScaleInversedSizeDataFunction(JsEngine engine, Scale scale){ 24 | this.engine = engine; 25 | this.scale = scale; 26 | } 27 | 28 | //#end region 29 | 30 | //#region METHODS 31 | 32 | @Override 33 | public Double apply(Object context, Object datum, int index) { 34 | 35 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 36 | 37 | Double value = Double.parseDouble(jsObject.eval("this.value").toString()); 38 | Double size = Double.parseDouble(jsObject.eval("this.size").toString()); 39 | 40 | Double scaledRightValueInPx = scale.applyForDouble(""+ (value+size)); 41 | Double scaledLeftValueInPx = scale.applyForDouble("" + value); 42 | Double sizeInPx = scaledRightValueInPx-scaledLeftValueInPx; 43 | return - sizeInPx; 44 | } 45 | 46 | //#end region 47 | 48 | } 49 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleInversedThirdDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.core.JsObject; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | import org.treez.javafxd3.d3.scales.QuantitativeScale; 7 | 8 | 9 | public class AxisScaleInversedThirdDataFunction implements DataFunction { 10 | 11 | //#region ATTRIBUTES 12 | 13 | JsEngine engine; 14 | 15 | private QuantitativeScale scale; 16 | 17 | private double maxValue; 18 | 19 | //#end region 20 | 21 | //#region CONSTRUCTORS 22 | 23 | /** 24 | * @param engine 25 | */ 26 | public AxisScaleInversedThirdDataFunction(JsEngine engine, QuantitativeScale scale, double maxValue){ 27 | this.engine = engine; 28 | this.scale = scale; 29 | this.maxValue = maxValue; 30 | } 31 | 32 | //#end region 33 | 34 | //#region METHODS 35 | 36 | @Override 37 | public Double apply(Object context, Object datum, int index) { 38 | 39 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 40 | 41 | Object secondValueObj = jsObject.eval("this[2]"); 42 | Double secondValue = Double.parseDouble(secondValueObj.toString()); 43 | 44 | Double scaledValue = scale.apply(secondValue).asDouble(); 45 | double inversedValue = maxValue-scaledValue; 46 | return inversedValue; 47 | } 48 | 49 | //#end region 50 | 51 | } 52 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleInversedValueDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.Scale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | /** 9 | * A datum function that extracts the value from a data object 10 | * and scales it with the given scale 11 | * 12 | */ 13 | public class AxisScaleInversedValueDataFunction implements DataFunction { 14 | 15 | //#region ATTRIBUTES 16 | 17 | private JsEngine engine; 18 | 19 | private Scale scale; 20 | 21 | private double maxValue; 22 | 23 | //#end region 24 | 25 | //#region CONSTRUCTORS 26 | 27 | /** 28 | * @param engine 29 | */ 30 | public AxisScaleInversedValueDataFunction(JsEngine engine,Scale scale, double maxValue){ 31 | this.engine = engine; 32 | this.scale = scale; 33 | this.maxValue = maxValue; 34 | } 35 | 36 | //#end region 37 | 38 | //#region METHODS 39 | 40 | @Override 41 | public Double apply(Object context, Object datum, int index) { 42 | 43 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 44 | Object valueObject = jsObject.eval("this.value"); 45 | Double scaledValue = scale.applyForDouble(valueObject.toString()); 46 | Double inversedValue = maxValue -scaledValue; 47 | return inversedValue; 48 | } 49 | 50 | //#end region 51 | 52 | } 53 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleKeyDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.Scale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | /** 9 | * A datum function that extracts the key value from a data object 10 | * and scales it with the given scale 11 | * 12 | */ 13 | public class AxisScaleKeyDataFunction implements DataFunction { 14 | 15 | //#region ATTRIBUTES 16 | 17 | private JsEngine engine; 18 | 19 | private Scale scale; 20 | 21 | //#end region 22 | 23 | //#region CONSTRUCTORS 24 | 25 | 26 | public AxisScaleKeyDataFunction(JsEngine engine, Scale scale){ 27 | this.engine = engine; 28 | this.scale = scale; 29 | } 30 | 31 | //#end region 32 | 33 | //#region METHODS 34 | 35 | @Override 36 | public Double apply(Object context, Object datum, int index) { 37 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 38 | Object firstValueObj = jsObject.eval("this.key"); 39 | Double scaledValue = scale.applyForDouble(firstValueObj.toString()); 40 | return scaledValue; 41 | } 42 | 43 | //#end region 44 | 45 | } 46 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleSecondDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.QuantitativeScale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class AxisScaleSecondDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine; 13 | 14 | private QuantitativeScale scale; 15 | 16 | //#end region 17 | 18 | //#region CONSTRUCTORS 19 | 20 | public AxisScaleSecondDataFunction(JsEngine engine,QuantitativeScale scale){ 21 | this.engine = engine; 22 | this.scale = scale; 23 | } 24 | 25 | //#end region 26 | 27 | //#region METHODS 28 | 29 | @Override 30 | public Double apply(Object context, Object datum, int index) { 31 | 32 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 33 | 34 | Object secondValueObj = jsObject.eval("this[1]"); 35 | Double scaledValue = scale.applyForDouble(secondValueObj.toString()); 36 | return scaledValue; 37 | } 38 | 39 | //#end region 40 | 41 | } 42 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleSizeDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.Scale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class AxisScaleSizeDataFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine; 13 | 14 | private Scale scale; 15 | 16 | //#end region 17 | 18 | //#region CONSTRUCTORS 19 | 20 | public AxisScaleSizeDataFunction(JsEngine engine, Scale scale) { 21 | this.engine = engine; 22 | this.scale = scale; 23 | } 24 | 25 | //#end region 26 | 27 | //#region METHODS 28 | 29 | @Override 30 | public Double apply(Object context, Object datum, int index) { 31 | 32 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 33 | 34 | Double value = Double.parseDouble(jsObject.eval("this.value").toString()); 35 | Double size = Double.parseDouble(jsObject.eval("this.size").toString()); 36 | 37 | Double scaledRightValueInPx = scale.applyForDouble("" + (value + size)); 38 | Double scaledLeftValueInPx = scale.applyForDouble("" + value); 39 | Double sizeInPx = scaledRightValueInPx - scaledLeftValueInPx; 40 | return sizeInPx; 41 | } 42 | 43 | //#end region 44 | 45 | } 46 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleThirdDatumAsSizeFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.QuantitativeScale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class AxisScaleThirdDatumAsSizeFunction implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine; 13 | 14 | private QuantitativeScale scale; 15 | 16 | //#end region 17 | 18 | //#region CONSTRUCTORS 19 | 20 | 21 | public AxisScaleThirdDatumAsSizeFunction(JsEngine engine, QuantitativeScale scale){ 22 | this.engine = engine; 23 | this.scale = scale; 24 | } 25 | 26 | //#end region 27 | 28 | //#region METHODS 29 | 30 | @Override 31 | public Double apply(Object context, Object datum, int index) { 32 | 33 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 34 | 35 | Object secondValueObj = jsObject.eval("this[2]"); 36 | Double scaledRightValue = scale.applyForDouble(secondValueObj.toString()); 37 | Double scaledLeftValue = scale.applyForDouble("0.0"); 38 | Double size = scaledRightValue-scaledLeftValue; 39 | return size; 40 | } 41 | 42 | //#end region 43 | 44 | } 45 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/axis/AxisScaleValueDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.axis; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | import org.treez.javafxd3.d3.scales.Scale; 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | /** 9 | * A datum function that extracts the value from a data object 10 | * and scales it with the given scale 11 | * 12 | */ 13 | public class AxisScaleValueDataFunction implements DataFunction { 14 | 15 | //#region ATTRIBUTES 16 | 17 | private JsEngine engine; 18 | 19 | private Scale scale; 20 | 21 | //#end region 22 | 23 | //#region CONSTRUCTORS 24 | 25 | public AxisScaleValueDataFunction(JsEngine engine, Scale scale){ 26 | this.engine = engine; 27 | this.scale = scale; 28 | } 29 | 30 | //#end region 31 | 32 | //#region METHODS 33 | 34 | @Override 35 | public Double apply(Object context, Object datum, int index) { 36 | 37 | JsObject jsObject = (JsObject) engine.toJsObjectIfNotSimpleType(datum); 38 | Object valueObject = jsObject.eval("this.value"); 39 | Double scaledValue = scale.applyForDouble(valueObject.toString()); 40 | return scaledValue; 41 | } 42 | 43 | //#end region 44 | 45 | } 46 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/wrapper/CompleteDataFunctionWrapper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.wrapper; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.functions.DataFunction; 5 | 6 | public class CompleteDataFunctionWrapper implements DataFunction { 7 | 8 | //#region ATTRIBUTES 9 | 10 | private JsEngine engine; 11 | 12 | private DataFunction wrappedFunction = null; 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public CompleteDataFunctionWrapper(JsEngine engine, DataFunction wrappedFunction) { 19 | this.engine = engine; 20 | this.wrappedFunction = wrappedFunction; 21 | } 22 | 23 | //#end region 24 | 25 | //#region METHODS 26 | 27 | @Override 28 | public R apply(Object context, Object datum, int index) { 29 | Object jsContext = engine.toJsObjectIfNotSimpleType(context); 30 | Object jsDatum = engine.toJsObjectIfNotSimpleType(datum); 31 | return wrappedFunction.apply(jsContext, jsDatum, index); 32 | } 33 | 34 | //#end region 35 | 36 | } 37 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/wrapper/ContextDataFunctionWrapper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.wrapper; 2 | 3 | import org.treez.javafxd3.d3.core.ConversionUtil; 4 | import org.treez.javafxd3.d3.core.JsEngine; 5 | import org.treez.javafxd3.d3.functions.DataFunction; 6 | import org.treez.javafxd3.d3.wrapper.Element; 7 | 8 | public class ContextDataFunctionWrapper implements DataFunction { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private JsEngine engine = null; 13 | 14 | private PlainDataFunction plainDataFunction = null; 15 | 16 | //#end region 17 | 18 | //#region CONSTRUCTORS 19 | 20 | public ContextDataFunctionWrapper(JsEngine engine, PlainDataFunction plainDataFunction) { 21 | this.engine = engine; 22 | this.plainDataFunction = plainDataFunction; 23 | } 24 | 25 | //#end region 26 | 27 | //#region METHODS 28 | 29 | @Override 30 | public R apply(Object context, Object datum, int index) { 31 | Element convertedContext = ConversionUtil.convertObjectTo(context, Element.class, engine); 32 | return plainDataFunction.apply(convertedContext); 33 | } 34 | 35 | //#end region 36 | 37 | } 38 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/wrapper/IndexDataFunctionWrapper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.wrapper; 2 | 3 | import org.treez.javafxd3.d3.functions.DataFunction; 4 | 5 | public class IndexDataFunctionWrapper implements DataFunction { 6 | 7 | //#region ATTRIBUTES 8 | 9 | private PlainDataFunction plainDataFunction = null; 10 | 11 | //#end region 12 | 13 | //#region CONSTRUCTORS 14 | 15 | public IndexDataFunctionWrapper(PlainDataFunction plainDataFunction) { 16 | this.plainDataFunction = plainDataFunction; 17 | } 18 | 19 | //#end region 20 | 21 | //#region METHODS 22 | 23 | @Override 24 | public R apply(Object context, Object datum, int index) { 25 | return plainDataFunction.apply(index); 26 | } 27 | 28 | //#end region 29 | 30 | } 31 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/data/wrapper/PlainDataFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.data.wrapper; 2 | 3 | public interface PlainDataFunction { 4 | 5 | R apply(A value); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/key/CompleteKeyFunctionWrapper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.key; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.functions.KeyFunction; 5 | 6 | public class CompleteKeyFunctionWrapper implements KeyFunction { 7 | 8 | //#region ATTRIBUTES 9 | 10 | private JsEngine engine; 11 | 12 | private KeyFunction wrappedFunction = null; 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public CompleteKeyFunctionWrapper(JsEngine engine, KeyFunction wrappedFunction) { 19 | this.engine = engine; 20 | this.wrappedFunction = wrappedFunction; 21 | } 22 | 23 | //#end region 24 | 25 | //#region METHODS 26 | 27 | @Override 28 | public R call(Object context, Object newDataArray, Object datum, int index) { 29 | Object jsContext = engine.toJsObjectIfNotSimpleType(context); 30 | Object jsNewDataArray = engine.toJsObjectIfNotSimpleType(newDataArray); 31 | Object jsDatum = engine.toJsObjectIfNotSimpleType(datum); 32 | return wrappedFunction.call(jsContext, jsNewDataArray, jsDatum, index); 33 | } 34 | 35 | //#end region 36 | 37 | } 38 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/functions/key/IndexKeyFunctionWrapper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.functions.key; 2 | 3 | import org.treez.javafxd3.d3.functions.KeyFunction; 4 | import org.treez.javafxd3.d3.functions.data.wrapper.PlainDataFunction; 5 | 6 | public class IndexKeyFunctionWrapper implements KeyFunction { 7 | 8 | //#region ATTRIBUTES 9 | 10 | private PlainDataFunction plainDataFunction = null; 11 | 12 | //#end region 13 | 14 | //#region CONSTRUCTORS 15 | 16 | public IndexKeyFunctionWrapper(PlainDataFunction plainDataFunction) { 17 | this.plainDataFunction = plainDataFunction; 18 | } 19 | 20 | //#end region 21 | 22 | //#region METHODS 23 | 24 | @Override 25 | public R call(Object context, Object newDataArray, Object datum, int index) { 26 | return plainDataFunction.apply(index); 27 | } 28 | 29 | //#end region 30 | 31 | } 32 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/geo/ConicProjection.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.geo; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.core.JsObject; 5 | 6 | /** 7 | * 8 | * 9 | */ 10 | public class ConicProjection extends Projection { 11 | 12 | //#region CONSTRUCTORS 13 | 14 | /** 15 | * @param engine 16 | * @param wrappedJsObject 17 | */ 18 | public ConicProjection(JsEngine engine, JsObject wrappedJsObject) { 19 | super(engine, wrappedJsObject); 20 | } 21 | 22 | //#end region 23 | 24 | //#region METHODS 25 | 26 | //#end region 27 | } 28 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/interpolators/AbstractInterpolatorFactory.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.interpolators; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | /** 9 | * Use this class as a base class to create {@link InterpolatorFactory} implementations that can be passed to D3#interpolators() 10 | * D3.interpolators().push(). 11 | *

12 | * 13 | * 14 | * 15 | * 16 | */ 17 | public abstract class AbstractInterpolatorFactory extends JavaScriptObject implements InterpolatorFactory { 18 | 19 | public AbstractInterpolatorFactory(JsEngine engine){ 20 | super(engine); 21 | } 22 | 23 | 24 | @Override 25 | public abstract Interpolator create(final Object a, final Object b); 26 | 27 | @Override 28 | public JsObject asJSOFunction(){ 29 | 30 | String interpolatorName = createNewTemporaryInstanceName(); 31 | String jsInterpolatorName = createNewTemporaryInstanceName(); 32 | 33 | JsObject d3JsObject = getD3(); 34 | d3JsObject.setMember(interpolatorName, this); 35 | 36 | String command = "this."+jsInterpolatorName+" = function(a, b) { return d3." + interpolatorName + ".create(a,b);};"; 37 | d3JsObject.eval(command); 38 | 39 | JsObject result = (JsObject) d3JsObject.eval("this." +jsInterpolatorName); 40 | 41 | 42 | 43 | return result; 44 | 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/interpolators/Interpolator.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.interpolators; 2 | 3 | 4 | 5 | import org.treez.javafxd3.d3.core.JsObject; 6 | 7 | /** 8 | * An interpolator is a function that maps a parametric value t in the domain [0,1] to a color, number or arbitrary value. 9 | *

10 | * D3 has many built-in interpolators to simplify the transitioning of arbitrary values; see the D3#interpolate*() methods. 11 | *

12 | * You should not directly implements this interface, but rather extend the class {@link CallableInterpolator}, if you need to pass your own 13 | * interpolator to D3. 14 | *

15 | * 16 | * 17 | * @param 18 | * 19 | */ 20 | public interface Interpolator { 21 | 22 | /** 23 | * Return the domain value corresponding to the parametric value t. 24 | * 25 | * @param t 26 | * the parameter 27 | * @return the corresponding value 28 | */ 29 | public T interpolate(Object t); 30 | 31 | /** 32 | * Return a one-arg JS function wrapping the interpolation. 33 | *

34 | * Consider using {@link CallableInterpolator} for your own interpolation. 35 | *

36 | * 37 | * @return the JS function 38 | */ 39 | public JsObject asJsFunction(); 40 | } 41 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/interpolators/InterpolatorFactory.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.interpolators; 2 | 3 | import org.treez.javafxd3.d3.core.JsObject; 4 | 5 | /** 6 | * Represents an object that can create an {@link Interpolator}. 7 | *

8 | * A factory should return null when no interpolators support the input arguments. 9 | * 10 | * 11 | * @param 12 | * 13 | */ 14 | public interface InterpolatorFactory { 15 | 16 | /** 17 | * Create an interpolator appropriate for interpolating the input value, or return null if the factory does not support the two 18 | * specified input values. 19 | *

20 | * 21 | * @param a 22 | * the start input param 23 | * @param b 24 | * the end input param 25 | * 26 | * @return an appropriate interpolator or null if the factory does not support the input values. 27 | */ 28 | Interpolator create(Object a, Object b); 29 | 30 | /** 31 | * Return a one-arg JS function wrapping the interpolation. 32 | *

33 | * Consider using {@link CallableInterpolator} for your own interpolation. 34 | *

35 | * 36 | * @return the JS function 37 | */ 38 | public JsObject asJSOFunction(); 39 | } 40 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/interpolators/JavascriptFunctionInterpolator.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.interpolators; 2 | 3 | import org.treez.javafxd3.d3.D3; 4 | import org.treez.javafxd3.d3.core.Value; 5 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 6 | 7 | import org.treez.javafxd3.d3.core.JsEngine; 8 | import org.treez.javafxd3.d3.core.JsObject; 9 | 10 | 11 | /** 12 | * An interpolator used when the interpolation function is provided by JSNI. 13 | *

14 | * This class is used by {@link D3} to allow java code to invoke built-in 15 | * interpolators. You should not instanciate this object unless you know what 16 | * you are doing. 17 | *

18 | */ 19 | public class JavascriptFunctionInterpolator extends JavaScriptObject implements Interpolator { 20 | 21 | //#region CONSTRUCTORS 22 | 23 | public JavascriptFunctionInterpolator(JsEngine engine, JsObject wrappedJsObject) { 24 | super(engine); 25 | setJsObject(wrappedJsObject); 26 | } 27 | 28 | //#end region 29 | 30 | //#region METHODS 31 | 32 | @Override 33 | public Value interpolate(Object t){ 34 | Object interpolationResult = callThis(t); 35 | return Value.create(engine, interpolationResult); 36 | } 37 | 38 | @Override 39 | public final JsObject asJsFunction() { 40 | return this.getJsObject(); 41 | } 42 | 43 | //#end region 44 | 45 | } 46 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/interpolators/JavascriptFunctionInterpolatorDecorator.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.interpolators; 2 | 3 | import org.treez.javafxd3.d3.core.Value; 4 | 5 | import org.treez.javafxd3.d3.core.JsObject; 6 | 7 | /** 8 | * 9 | * @param 10 | */ 11 | public class JavascriptFunctionInterpolatorDecorator implements Interpolator { 12 | 13 | //#region ATTRIBUTES 14 | 15 | protected JavascriptFunctionInterpolator delegate; 16 | 17 | //#end region 18 | 19 | //#region CONSTRUCTORS 20 | 21 | 22 | public JavascriptFunctionInterpolatorDecorator(final JavascriptFunctionInterpolator delegate) { 23 | this.delegate = delegate; 24 | } 25 | 26 | //#end region 27 | 28 | //#region METHODS 29 | 30 | @Override 31 | public JsObject asJsFunction() { 32 | return delegate.asJsFunction(); 33 | } 34 | 35 | @Override 36 | public T interpolate(Object t) { 37 | return cast(delegate.interpolate(t)); 38 | } 39 | 40 | /** 41 | * Cast the given value to the correct type. 42 | * @param v 43 | * @return 44 | */ 45 | public T cast(final Value v) { 46 | return v.as(); 47 | } 48 | 49 | //#end region 50 | } 51 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/interpolators/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * TODO: interpolator factory API is a work in progress. 3 | *

4 | * 5 | * @since 1.0 6 | */ 7 | package org.treez.javafxd3.d3.interpolators; 8 | 9 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/layout/Cluster.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.layout; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.core.JsObject; 5 | 6 | /** 7 | * The cluster layout produces dendrograms: node-link diagrams that place leaf 8 | * nodes of the tree at the same depth. 9 | *

10 | * For example, a cluster layout can be used to organize software classes in a 11 | * package hierarchy: 12 | * 13 | *

14 | * Like other classes in D3, layouts follow the method chaining pattern where 15 | * setter methods return the layout itself, allowing multiple setters to be 16 | * invoked in a concise statement. 17 | * 18 | * 19 | * 20 | */ 21 | public class Cluster extends HierarchicalLayout { 22 | 23 | //#region CONSTRUCTORS 24 | 25 | /** 26 | * Constructor 27 | * 28 | * @param engine 29 | * @param wrappedJsObject 30 | */ 31 | public Cluster(JsEngine engine, JsObject wrappedJsObject) { 32 | super(engine, wrappedJsObject); 33 | } 34 | 35 | //#end region 36 | 37 | //#region METHODS 38 | 39 | /** 40 | * @param width 41 | * @param height 42 | * @return 43 | */ 44 | public Cluster size(int width, int height){ 45 | String command = "this.size(["+width+", "+height+"]);"; 46 | JsObject result = evalForJsObject(command); 47 | return new Cluster(engine, result); 48 | }; 49 | 50 | //#end region 51 | 52 | } 53 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/scales/QuantitativeScale.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.scales; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.core.JsObject; 5 | 6 | /** 7 | * Quantitative scales have a continuous domain: 8 | *

    9 | *
  • {@link ContinuousQuantitativeScale} have a continuous output range 10 | *
  • {@link DiscreteQuantitativeScale} have a discrete output range 11 | *
12 | */ 13 | public abstract class QuantitativeScale> extends Scale { 14 | 15 | //#region CONSTRUCTORS 16 | 17 | /** 18 | * Constructor 19 | * 20 | * @param engine 21 | * @param wrappedJsObject 22 | */ 23 | public QuantitativeScale(JsEngine engine, JsObject wrappedJsObject) { 24 | super(engine, wrappedJsObject); 25 | } 26 | 27 | //#end region 28 | 29 | } 30 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/tweens/TweenFunction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.tweens; 2 | 3 | import org.treez.javafxd3.d3.core.Transition; 4 | import org.treez.javafxd3.d3.interpolators.Interpolator; 5 | 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | /** 9 | * A function returning an {@link Interpolator} used to tween elements attribute or styles within {@link Transition}s. 10 | *

11 | * @see Official attrTween function 12 | * 13 | * @param 14 | * 15 | */ 16 | public interface TweenFunction { 17 | 18 | 19 | /** 20 | * Returns a java script interpolation method interpolate(doubleValue) as JsObject 21 | */ 22 | JsObject apply(Object context, Object datum, int index, Object value); 23 | } 24 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/wrapper/D3NodeFactory.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.wrapper; 2 | 3 | import org.treez.javafxd3.d3.core.Selection; 4 | 5 | /** 6 | * Factory for d3 nodes 7 | */ 8 | public interface D3NodeFactory { 9 | 10 | /** 11 | * Creates a d3 node, using the given selection as a parent 12 | * @param selection 13 | * @return 14 | */ 15 | Selection createInParentSelection(Selection selection); 16 | 17 | /** 18 | * Removes a d3 node, using the given selection as a parent 19 | * @param selection 20 | * @return 21 | */ 22 | Selection remove(Selection selection); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/wrapper/JsArrayMixed.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.wrapper; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.core.JsObject; 5 | 6 | /** 7 | * 8 | * 9 | */ 10 | public class JsArrayMixed extends JavaScriptObject { 11 | 12 | //#region CONSTRUCTORS 13 | 14 | /** 15 | * Constructor 16 | * @param engine 17 | */ 18 | public JsArrayMixed(JsEngine engine) { 19 | super(engine); 20 | } 21 | 22 | /** 23 | * Constructor 24 | * @param engine 25 | * @param wrappedJsObject 26 | */ 27 | public JsArrayMixed(JsEngine engine, JsObject wrappedJsObject) { 28 | super(engine); 29 | setJsObject(wrappedJsObject); 30 | 31 | } 32 | 33 | //#end region 34 | 35 | } 36 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/wrapper/JsArrayNumber.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.wrapper; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.core.JsObject; 5 | 6 | /** 7 | * 8 | * 9 | */ 10 | public class JsArrayNumber extends JavaScriptObject { 11 | 12 | //#region CONSTRUCTORS 13 | 14 | /** 15 | * Constructor 16 | * @param engine 17 | */ 18 | public JsArrayNumber(JsEngine engine) { 19 | super(engine); 20 | } 21 | 22 | /** 23 | * Constructor 24 | * @param engine 25 | * @param wrappedJsObject 26 | */ 27 | public JsArrayNumber(JsEngine engine, JsObject wrappedJsObject) { 28 | super(engine); 29 | setJsObject(wrappedJsObject); 30 | } 31 | 32 | //#end region 33 | 34 | } 35 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/wrapper/Node.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.wrapper; 2 | 3 | import org.treez.javafxd3.d3.arrays.Array; 4 | import org.treez.javafxd3.d3.core.ConversionUtil; 5 | 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | import org.treez.javafxd3.d3.core.JsObject; 8 | 9 | public class Node extends JavaScriptObject { 10 | 11 | //#region CONSTRUCTORS 12 | 13 | public Node(JsEngine engine, JsObject wrappedJsObject) { 14 | super(engine); 15 | setJsObject(wrappedJsObject); 16 | } 17 | 18 | //#end region 19 | 20 | //#region METHODS 21 | 22 | public void appendChild(Node child) { 23 | call("appendChild", child.getJsObject()); 24 | } 25 | 26 | public T cast(Class targetClass) { 27 | return ConversionUtil.convertObjectTo(getJsObject(), targetClass, engine); 28 | } 29 | 30 | public Array children() { 31 | String command = "this.children"; 32 | JsObject result = evalForJsObject(command); 33 | if(result==null){ 34 | return null; 35 | } 36 | return new Array<>(engine, result); 37 | } 38 | 39 | //#end region 40 | 41 | } 42 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/wrapper/NodeList.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.wrapper; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | 5 | /** 6 | * Represents a list of nodes 7 | * 8 | * 9 | * @param 10 | */ 11 | public class NodeList extends JavaScriptObject { 12 | 13 | //#region CONSTRUCTORS 14 | 15 | /** 16 | * Constructor 17 | * @param engine 18 | */ 19 | public NodeList(JsEngine engine){ 20 | super(engine); 21 | } 22 | 23 | //#end region 24 | 25 | } 26 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/wrapper/Sort.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.wrapper; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.core.JsObject; 5 | 6 | /** 7 | */ 8 | public class Sort extends JavaScriptObject { 9 | 10 | //#region CONSTRUCTORS 11 | 12 | 13 | public Sort(JsEngine engine, JsObject wrappedJsObject) { 14 | super(engine, wrappedJsObject); 15 | } 16 | 17 | //#end region 18 | 19 | } 20 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/wrapper/Style.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.wrapper; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.treez.javafxd3.d3.core.Selection; 7 | 8 | /** 9 | * 10 | */ 11 | public class Style { 12 | 13 | //#region ATTRIBUTES 14 | 15 | Map styleValues = new HashMap<>(); 16 | 17 | //#end region 18 | 19 | //#region CONSTRUCTORS 20 | 21 | public Style(){ } 22 | 23 | //#end region 24 | 25 | //#region METHODS 26 | 27 | public void apply(Selection labelSelection) { 28 | for(String styleProperty: styleValues.keySet()){ 29 | String value = styleValues.get(styleProperty); 30 | labelSelection.style(styleProperty, value); 31 | } 32 | } 33 | 34 | //#end region 35 | 36 | //#region ACCESSORS 37 | 38 | public void setProperty(String styleProperty, String value) { 39 | styleValues.put(styleProperty, value); 40 | } 41 | 42 | 43 | 44 | //#end region 45 | 46 | } 47 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/wrapper/Widget.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.wrapper; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | import org.treez.javafxd3.d3.core.JsObject; 5 | 6 | public class Widget extends JavaScriptObject { 7 | 8 | //#region CONSTRUCTORS 9 | 10 | public Widget(JsEngine engine, JsObject wrappedJsObject){ 11 | super(engine); 12 | setJsObject(wrappedJsObject); 13 | } 14 | 15 | //#end region 16 | 17 | //#region ACCESSORS 18 | 19 | public Element getElement() { 20 | JsObject result = call("getElement"); 21 | return new Element(engine, result); 22 | } 23 | 24 | //#end region 25 | 26 | } 27 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/d3/wrapper/canvas/CanvasElement.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.d3.wrapper.canvas; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class CanvasElement extends JavaScriptObject { 9 | 10 | //#region CONSTRUCTORS 11 | 12 | public CanvasElement(JsEngine engine, JsObject wrappedJsObject) { 13 | super(engine, wrappedJsObject); 14 | } 15 | 16 | //#end region 17 | 18 | //#region ACCESSORS 19 | 20 | public Context2d getContext2d() { 21 | 22 | String command = "this.getContext('2d')"; 23 | JsObject result = evalForJsObject(command); 24 | if (result == null) { 25 | return null; 26 | } 27 | 28 | return new Context2d(engine, result); 29 | 30 | } 31 | 32 | //#end region 33 | } 34 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/javafx/EnumValueProvider.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.javafx; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * This interface needs to be implemented by enums that should be used with the 7 | * EnumComboBox 8 | */ 9 | public interface EnumValueProvider> { 10 | 11 | /** 12 | * Returns all enum values as a list of corresponding strings 13 | */ 14 | List getValues(); 15 | 16 | /** 17 | * Returns the enum value that corresponds to the given string. 18 | */ 19 | T fromString(String value); 20 | 21 | /** 22 | * Returns the string that corresponds to the value 23 | */ 24 | @Override 25 | String toString(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/javafx/JavaFxJsEngine.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.javafx; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | 5 | import javafx.scene.web.WebEngine; 6 | import netscape.javascript.JSObject; 7 | 8 | public class JavaFxJsEngine implements JsEngine { 9 | 10 | //#region ATTRIBUTES 11 | 12 | private WebEngine wrappedJsEngine; 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public JavaFxJsEngine(WebEngine wrappedJsEngine) { 19 | this.wrappedJsEngine = wrappedJsEngine; 20 | } 21 | 22 | //#end region 23 | 24 | //#region METHODS 25 | 26 | @Override 27 | public Object executeScript(String script) { 28 | Object result = wrappedJsEngine.executeScript(script); 29 | return JavaFxJsObject.wrapIfIsJSObject(result); 30 | } 31 | 32 | @Override 33 | public Object toJsObjectIfNotSimpleType(Object argument) { 34 | 35 | boolean isJSObject = argument instanceof JSObject; 36 | if(isJSObject){ 37 | JSObject jsArgument = (JSObject) argument; 38 | return new JavaFxJsObject(jsArgument); 39 | } 40 | return argument; 41 | } 42 | 43 | //#end region 44 | 45 | } 46 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/javafx/PlotInstruction.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.javafx; 2 | 3 | public interface PlotInstruction { 4 | 5 | void execute(FunctionPlotter plotter); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/javafx/SaveHelper.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.javafx; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.io.PrintWriter; 6 | 7 | import javafx.stage.FileChooser; 8 | import javafx.stage.FileChooser.ExtensionFilter; 9 | 10 | /** 11 | * Helps to export svg content from the JavaFx JsEngine 12 | * 13 | */ 14 | public class SaveHelper { 15 | 16 | /** 17 | * Saves the given svg content as svg file after asking for the 18 | * file path 19 | * 20 | * @param svgContent 21 | */ 22 | public void saveSvg(String svgContent) { 23 | 24 | FileChooser fileChooser = new FileChooser(); 25 | fileChooser.setTitle("Export SVG"); 26 | fileChooser.setInitialFileName("svgExport"); 27 | ExtensionFilter extensionFilter = new ExtensionFilter("Scalable Vector Graphics (SVG)","*.svg"); 28 | fileChooser.getExtensionFilters().add(extensionFilter); 29 | File file = fileChooser.showSaveDialog(null); 30 | 31 | if (file != null) { 32 | try { 33 | PrintWriter out = new PrintWriter(file); 34 | out.print(svgContent); 35 | out.close(); 36 | } catch (FileNotFoundException e) { 37 | // 38 | } 39 | } 40 | } 41 | 42 | 43 | /** 44 | * Saves the given svg content as svg file at the given file path 45 | */ 46 | public void saveSvgTo(String svgContent, String filePath) { 47 | 48 | File file = new File(filePath); 49 | if (file != null) { 50 | try { 51 | PrintWriter out = new PrintWriter(file); 52 | out.print(svgContent); 53 | out.close(); 54 | } catch (FileNotFoundException e) { 55 | // 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/PlotResult.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class PlotResult extends JavaScriptObject { 9 | 10 | //#region ATTRIBUTES 11 | 12 | //#end region 13 | 14 | //#region CONSTRUCTORS 15 | 16 | public PlotResult(JsEngine engine, JsObject jsObject) { 17 | super(engine,jsObject); 18 | } 19 | 20 | //#end region 21 | 22 | //#region METHODS 23 | 24 | //#end region 25 | 26 | } 27 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/configuration/Configuration.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.configuration; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class Configuration extends JavaScriptObject { 9 | 10 | //#region ATTRIBUTES 11 | 12 | 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public Configuration(JsEngine engine, JsObject jsObject) { 19 | super(engine,jsObject); 20 | } 21 | 22 | public Configuration(JsEngine engine) { 23 | super(engine); 24 | setEmptyObjectAsJsObject(); 25 | } 26 | 27 | //#end region 28 | 29 | //#region METHODS 30 | 31 | //#end region 32 | 33 | } 34 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/Font.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class Font extends JavaScriptObject { 9 | 10 | //#region CONSTRUCTORS 11 | 12 | public Font(JsEngine engine, JsObject jsObject) { 13 | super(engine,jsObject); 14 | } 15 | 16 | public Font(JsEngine engine) { 17 | super(engine); 18 | setEmptyObjectAsJsObject(); 19 | } 20 | 21 | //#end region 22 | 23 | //#region ACCESSORS 24 | 25 | public void setColor(String color) { 26 | setMember("color", color); 27 | } 28 | 29 | public void setFamily(String fontFamily) { 30 | setMember("family", fontFamily); 31 | } 32 | 33 | public void setSize(int size) { 34 | setMember("size", size); 35 | } 36 | 37 | //#end region 38 | 39 | } 40 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/Marker.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | 9 | public class Marker extends JavaScriptObject { 10 | 11 | //#region ATTRIBUTES 12 | 13 | 14 | 15 | //#end region 16 | 17 | //#region CONSTRUCTORS 18 | 19 | public Marker(JsEngine engine, JsObject jsObject) { 20 | super(engine,jsObject); 21 | } 22 | 23 | public Marker(JsEngine engine) { 24 | super(engine); 25 | setEmptyObjectAsJsObject(); 26 | } 27 | 28 | //#end region 29 | 30 | //#region METHODS 31 | 32 | public void setType(String type){ 33 | setMember("type", type); 34 | } 35 | 36 | public String getType(String type){ 37 | return getMemberForString("type"); 38 | } 39 | 40 | public void setMarker(Marker marker){ 41 | setMember("marker", marker.getJsObject()); 42 | } 43 | 44 | public Marker getMarker(){ 45 | JsObject result = getMember("marker"); 46 | return new Marker(engine, result); 47 | } 48 | 49 | //#end region 50 | 51 | } 52 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/PlotlyType.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | 7 | public enum PlotlyType { 8 | 9 | //#region VALUES 10 | 11 | AREA("area"), 12 | BAR("bar"), 13 | BOX("box"), 14 | CHOROPLETH("choropleth"), 15 | HEATMAP("heatmap"), 16 | HISTOGRAM("histogram"), 17 | HISTOGRAM_2D("histogram2d"), 18 | HISTOGRAM_2D_CONTOUR("histogram2dcountour"), 19 | MESH("mesh3d"), 20 | PIE("pie"), 21 | SCATTER("scatter"), 22 | SCATTER_3D("scatter3d"), 23 | SCATTER_GEO("scattergeo"), 24 | SCATTER_GL("scattergl"), 25 | SURFACE("surface"), 26 | CONTOUR("contour"); 27 | 28 | //#end region 29 | 30 | //#region ATTRIBUTES 31 | 32 | String value; 33 | 34 | //#end region 35 | 36 | //#region CONSTRUCTORS 37 | 38 | PlotlyType(String value){ 39 | this.value=value; 40 | } 41 | 42 | //#end region 43 | 44 | //#region METHODS 45 | 46 | @Override 47 | public String toString() { 48 | return value; 49 | } 50 | 51 | public static PlotlyType fromString(final String value) { 52 | return valueOf(value.toUpperCase().replace('-', '_')); 53 | } 54 | 55 | public List getValues() { 56 | List values = new ArrayList<>(); 57 | for (PlotlyType enumValue : values()) { 58 | String stringValue = enumValue.value; 59 | values.add(stringValue); 60 | } 61 | return values; 62 | } 63 | 64 | //#end region 65 | 66 | } 67 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/contour/ColorScale.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.contour; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.treez.javafxd3.javafx.EnumValueProvider; 7 | 8 | public enum ColorScale implements EnumValueProvider { 9 | 10 | //#region VALUES 11 | 12 | BLACKBODY("Blackbody"), // 13 | BLUERED("Bluered"), // 14 | EARTH("Earth"), // 15 | ELECTRIC("Electric"), // 16 | GREENS("Greens"), // 17 | GREYS("Greys"), // 18 | HOT("Hot"), // 19 | JET("Jet"), // 20 | PICNIC("Picnic"), // 21 | PORTLAND("Portland"), // 22 | RDBU("RdBu"), // 23 | YIGNBU("YIGnBu"), // 24 | YIORD("YIOrRd"); 25 | 26 | //#end region 27 | 28 | //#region ATTRIBUTES 29 | 30 | String value; 31 | 32 | //#end region 33 | 34 | //#region CONSTRUCTORS 35 | 36 | ColorScale(String value) { 37 | this.value = value; 38 | } 39 | 40 | //#end region 41 | 42 | //#region METHODS 43 | 44 | @Override 45 | public String toString() { 46 | return value; 47 | } 48 | 49 | @Override 50 | public ColorScale fromString(final String value) { 51 | return valueOf(value.toUpperCase().replace("-", "_")); 52 | } 53 | 54 | @Override 55 | public List getValues() { 56 | List values = new ArrayList<>(); 57 | for (ColorScale enumValue : values()) { 58 | String stringValue = enumValue.value; 59 | values.add(stringValue); 60 | } 61 | return values; 62 | } 63 | 64 | //#end region 65 | 66 | } 67 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/contour/Coloring.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.contour; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | 7 | 8 | public enum Coloring implements org.treez.javafxd3.javafx.EnumValueProvider{ 9 | 10 | //#region VALUES 11 | 12 | FILL("fill"), // 13 | HEATMAP("heatmap"), // 14 | LINES("lines"); // ("none" is not used here) 15 | 16 | //#end region 17 | 18 | //#region ATTRIBUTES 19 | 20 | String value; 21 | 22 | //#end region 23 | 24 | //#region CONSTRUCTORS 25 | 26 | Coloring(String value) { 27 | this.value = value; 28 | } 29 | 30 | //#end region 31 | 32 | //#region METHODS 33 | 34 | @Override 35 | public String toString() { 36 | return value; 37 | } 38 | 39 | @Override 40 | public Coloring fromString(final String value) { 41 | return valueOf(value.toUpperCase().replace("-", "_")); 42 | } 43 | 44 | @Override 45 | public List getValues() { 46 | List values = new ArrayList<>(); 47 | for (Coloring enumValue : values()) { 48 | String stringValue = enumValue.value; 49 | values.add(stringValue); 50 | } 51 | return values; 52 | } 53 | 54 | //#end region 55 | 56 | } 57 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/contour/colorbar/ExponentFormat.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.contour.colorbar; 2 | 3 | 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public enum ExponentFormat { 9 | 10 | //#region VALUES 11 | 12 | NONE("none"), // 13 | E_LOWER_CASE("e"), // 14 | E_UPPER_CASE("E"), // 15 | POWER("power"), // 16 | SI("SI"), // 17 | B("B"); 18 | 19 | //#end region 20 | 21 | //#region ATTRIBUTES 22 | 23 | String value; 24 | 25 | //#end region 26 | 27 | //#region CONSTRUCTORS 28 | 29 | ExponentFormat(String value) { 30 | this.value = value; 31 | } 32 | 33 | //#end region 34 | 35 | //#region METHODS 36 | 37 | @Override 38 | public String toString() { 39 | return value; 40 | } 41 | 42 | public static ExponentFormat fromString(final String value) { 43 | return valueOf(value.toUpperCase().replace("-", "_")); 44 | } 45 | 46 | public List getValues() { 47 | List values = new ArrayList<>(); 48 | for (ExponentFormat enumValue : values()) { 49 | String stringValue = enumValue.value; 50 | values.add(stringValue); 51 | } 52 | return values; 53 | } 54 | 55 | //#end region 56 | 57 | } 58 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/contour/colorbar/HorizontalPosition.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.contour.colorbar; 2 | 3 | 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public enum HorizontalPosition { 9 | 10 | //#region VALUES 11 | 12 | LEFT("left"), // 13 | MIDDLE("middle"), // 14 | RIGHT("right"); 15 | 16 | //#end region 17 | 18 | //#region ATTRIBUTES 19 | 20 | String value; 21 | 22 | //#end region 23 | 24 | //#region CONSTRUCTORS 25 | 26 | HorizontalPosition(String value) { 27 | this.value = value; 28 | } 29 | 30 | //#end region 31 | 32 | //#region METHODS 33 | 34 | @Override 35 | public String toString() { 36 | return value; 37 | } 38 | 39 | public static HorizontalPosition fromString(final String value) { 40 | return valueOf(value.toUpperCase().replace("-", "_")); 41 | } 42 | 43 | public List getValues() { 44 | List values = new ArrayList<>(); 45 | for (HorizontalPosition enumValue : values()) { 46 | String stringValue = enumValue.value; 47 | values.add(stringValue); 48 | } 49 | return values; 50 | } 51 | 52 | //#end region 53 | 54 | } 55 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/contour/colorbar/LenMode.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.contour.colorbar; 2 | 3 | 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public enum LenMode { 9 | 10 | //#region VALUES 11 | 12 | FRACTION("fraction"), // 13 | PIXELS("pixels"); 14 | 15 | //#end region 16 | 17 | //#region ATTRIBUTES 18 | 19 | String value; 20 | 21 | //#end region 22 | 23 | //#region CONSTRUCTORS 24 | 25 | LenMode(String value) { 26 | this.value = value; 27 | } 28 | 29 | //#end region 30 | 31 | //#region METHODS 32 | 33 | @Override 34 | public String toString() { 35 | return value; 36 | } 37 | 38 | public static LenMode fromString(final String value) { 39 | return valueOf(value.toUpperCase().replace("-", "_")); 40 | } 41 | 42 | public List getValues() { 43 | List values = new ArrayList<>(); 44 | for (LenMode enumValue : values()) { 45 | String stringValue = enumValue.value; 46 | values.add(stringValue); 47 | } 48 | return values; 49 | } 50 | 51 | //#end region 52 | 53 | } 54 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/contour/colorbar/ShowDetail.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.contour.colorbar; 2 | 3 | 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public enum ShowDetail { 9 | 10 | //#region VALUES 11 | 12 | ALL("all"), // 13 | FIRST("first"), // 14 | LAST("last"), // 15 | NONE("none"); 16 | 17 | //#end region 18 | 19 | //#region ATTRIBUTES 20 | 21 | String value; 22 | 23 | //#end region 24 | 25 | //#region CONSTRUCTORS 26 | 27 | ShowDetail(String value) { 28 | this.value = value; 29 | } 30 | 31 | //#end region 32 | 33 | //#region METHODS 34 | 35 | @Override 36 | public String toString() { 37 | return value; 38 | } 39 | 40 | public static ShowDetail fromString(final String value) { 41 | return valueOf(value.toUpperCase().replace("-", "_")); 42 | } 43 | 44 | public List getValues() { 45 | List values = new ArrayList<>(); 46 | for (ShowDetail enumValue : values()) { 47 | String stringValue = enumValue.value; 48 | values.add(stringValue); 49 | } 50 | return values; 51 | } 52 | 53 | //#end region 54 | 55 | } 56 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/contour/colorbar/TickMode.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.contour.colorbar; 2 | 3 | 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public enum TickMode { 9 | 10 | //#region VALUES 11 | 12 | AUTO("auto"), // 13 | LINEAR("linar"), // 14 | ARRAY("array"); 15 | 16 | //#end region 17 | 18 | //#region ATTRIBUTES 19 | 20 | String value; 21 | 22 | //#end region 23 | 24 | //#region CONSTRUCTORS 25 | 26 | TickMode(String value) { 27 | this.value = value; 28 | } 29 | 30 | //#end region 31 | 32 | //#region METHODS 33 | 34 | @Override 35 | public String toString() { 36 | return value; 37 | } 38 | 39 | public static TickMode fromString(final String value) { 40 | return valueOf(value.toUpperCase().replace("-", "_")); 41 | } 42 | 43 | public List getValues() { 44 | List values = new ArrayList<>(); 45 | for (TickMode enumValue : values()) { 46 | String stringValue = enumValue.value; 47 | values.add(stringValue); 48 | } 49 | return values; 50 | } 51 | 52 | //#end region 53 | 54 | } 55 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/contour/colorbar/TickPosition.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.contour.colorbar; 2 | 3 | 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.treez.javafxd3.javafx.EnumValueProvider; 9 | 10 | public enum TickPosition implements EnumValueProvider{ 11 | 12 | //#region VALUES 13 | 14 | OUTSIDE("outside"), // 15 | INSIDE("inside"), // 16 | NONE(""); 17 | 18 | //#end region 19 | 20 | //#region ATTRIBUTES 21 | 22 | String value; 23 | 24 | //#end region 25 | 26 | //#region CONSTRUCTORS 27 | 28 | TickPosition(String value) { 29 | this.value = value; 30 | } 31 | 32 | //#end region 33 | 34 | //#region METHODS 35 | 36 | @Override 37 | public String toString() { 38 | return value; 39 | } 40 | 41 | @Override 42 | public TickPosition fromString(final String value) { 43 | return valueOf(value.toUpperCase().replace("-", "_")); 44 | } 45 | 46 | @Override 47 | public List getValues() { 48 | List values = new ArrayList<>(); 49 | for (TickPosition enumValue : values()) { 50 | String stringValue = enumValue.value; 51 | values.add(stringValue); 52 | } 53 | return values; 54 | } 55 | 56 | //#end region 57 | 58 | } 59 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/contour/colorbar/TitleSide.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.contour.colorbar; 2 | 3 | 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.treez.javafxd3.javafx.EnumValueProvider; 9 | 10 | public enum TitleSide implements EnumValueProvider{ 11 | 12 | //#region VALUES 13 | 14 | TOP("top"), // 15 | RIGHT("right"), // 16 | BOTTOM("bottom"); 17 | 18 | //#end region 19 | 20 | //#region ATTRIBUTES 21 | 22 | String value; 23 | 24 | //#end region 25 | 26 | //#region CONSTRUCTORS 27 | 28 | TitleSide(String value) { 29 | this.value = value; 30 | } 31 | 32 | //#end region 33 | 34 | //#region METHODS 35 | 36 | @Override 37 | public String toString() { 38 | return value; 39 | } 40 | 41 | @Override 42 | public TitleSide fromString(final String value) { 43 | return valueOf(value.toUpperCase().replace("-", "_")); 44 | } 45 | 46 | @Override 47 | public List getValues() { 48 | List values = new ArrayList<>(); 49 | for (TitleSide enumValue : values()) { 50 | String stringValue = enumValue.value; 51 | values.add(stringValue); 52 | } 53 | return values; 54 | } 55 | 56 | //#end region 57 | 58 | } 59 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/contour/colorbar/VerticalPosition.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.contour.colorbar; 2 | 3 | 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public enum VerticalPosition { 9 | 10 | //#region VALUES 11 | 12 | TOP("top"), // 13 | MIDDLE("middle"), // 14 | BOTTOM("bottom"); 15 | 16 | //#end region 17 | 18 | //#region ATTRIBUTES 19 | 20 | String value; 21 | 22 | //#end region 23 | 24 | //#region CONSTRUCTORS 25 | 26 | VerticalPosition(String value) { 27 | this.value = value; 28 | } 29 | 30 | //#end region 31 | 32 | //#region METHODS 33 | 34 | @Override 35 | public String toString() { 36 | return value; 37 | } 38 | 39 | public static VerticalPosition fromString(final String value) { 40 | return valueOf(value.toUpperCase().replace("-", "_")); 41 | } 42 | 43 | public List getValues() { 44 | List values = new ArrayList<>(); 45 | for (VerticalPosition enumValue : values()) { 46 | String stringValue = enumValue.value; 47 | values.add(stringValue); 48 | } 49 | return values; 50 | } 51 | 52 | //#end region 53 | 54 | } 55 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/line/Dash.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.line; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public enum Dash { 7 | 8 | //#region VALUES 9 | 10 | SOLID("solid"), // 11 | DOT("dot"), // 12 | DASH("dash"), // 13 | LONGDASH("longdash"), // 14 | DASHDOT("dashdot"), // 15 | LONGDASHDOT("longdashdot"); 16 | 17 | //#end region 18 | 19 | //#region ATTRIBUTES 20 | 21 | String value; 22 | 23 | //#end region 24 | 25 | //#region CONSTRUCTORS 26 | 27 | Dash(String value) { 28 | this.value = value; 29 | } 30 | 31 | //#end region 32 | 33 | //#region METHODS 34 | 35 | @Override 36 | public String toString() { 37 | return value; 38 | } 39 | 40 | public static Dash fromString(final String value) { 41 | return valueOf(value.toUpperCase().replace("-", "_")); 42 | } 43 | 44 | public List getValues() { 45 | List values = new ArrayList<>(); 46 | for (Dash enumValue : values()) { 47 | String stringValue = enumValue.value; 48 | values.add(stringValue); 49 | } 50 | return values; 51 | } 52 | 53 | //#end region 54 | 55 | } 56 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/line/Line.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.line; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class Line extends JavaScriptObject { 9 | 10 | //#region CONSTRUCTORS 11 | 12 | public Line(JsEngine engine, JsObject jsObject) { 13 | super(engine,jsObject); 14 | } 15 | 16 | public Line(JsEngine engine) { 17 | super(engine); 18 | setEmptyObjectAsJsObject(); 19 | } 20 | 21 | //#end region 22 | 23 | //#region METHODS 24 | 25 | public void setColor(String color){ 26 | setMember("color", color); 27 | } 28 | 29 | public void setWidth(double widthInPx){ 30 | setMember("width", widthInPx); 31 | } 32 | 33 | public void setDash(Dash dash){ 34 | setMember("dash", dash.toString()); 35 | } 36 | 37 | public void setDash(double dashLengthInPx){ 38 | setMember("dash", dashLengthInPx); 39 | } 40 | 41 | public void setShape(LineShape lineShape){ 42 | setMember("shape", lineShape.toString()); 43 | } 44 | 45 | /** 46 | * Sets the amount of smoothing for the contour lines, where "0" corresponds to no smoothing. 47 | * Max value: 1.3 48 | */ 49 | public void setSmoothing(double smoothing){ 50 | setMember("smoothing", smoothing); 51 | } 52 | 53 | 54 | 55 | //#end region 56 | 57 | } 58 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/data/line/LineShape.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.data.line; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * Determines the line shape. With "spline" the lines are drawn using spline interpolation. 8 | * The other available values correspond to step-wise line shapes. 9 | */ 10 | public enum LineShape { 11 | 12 | //#region VALUES 13 | 14 | LINEAR("linear"), // 15 | SPLINE("spline"), // 16 | HV("hv"), // 17 | VH("vh"), // 18 | HVH("hvh"), // 19 | VHV("vhv"); // 20 | 21 | 22 | //#end region 23 | 24 | //#region ATTRIBUTES 25 | 26 | String value; 27 | 28 | //#end region 29 | 30 | //#region CONSTRUCTORS 31 | 32 | LineShape(String value) { 33 | this.value = value; 34 | } 35 | 36 | //#end region 37 | 38 | //#region METHODS 39 | 40 | @Override 41 | public String toString() { 42 | return value; 43 | } 44 | 45 | public static LineShape fromString(final String value) { 46 | return valueOf(value.toUpperCase().replace("-", "_")); 47 | } 48 | 49 | public List getValues() { 50 | List values = new ArrayList<>(); 51 | for (LineShape enumValue : values()) { 52 | String stringValue = enumValue.value; 53 | values.add(stringValue); 54 | } 55 | return values; 56 | } 57 | 58 | //#end region 59 | 60 | } 61 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/layout/Axis.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.layout; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class Axis extends JavaScriptObject { 9 | 10 | //#region ATTRIBUTES 11 | 12 | 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public Axis(JsEngine engine, JsObject jsObject) { 19 | super(engine,jsObject); 20 | } 21 | 22 | public Axis(JsEngine engine) { 23 | super(engine); 24 | setEmptyObjectAsJsObject(); 25 | } 26 | 27 | //#end region 28 | 29 | //#region ACCESSORS 30 | 31 | public void setRange(double min, double max){ 32 | String command = "this.range = ["+min+","+max+"]"; 33 | eval(command); 34 | } 35 | 36 | public void setShowTickLabels(boolean showTickLabels) { 37 | setMember("showticklabels", showTickLabels); 38 | } 39 | 40 | public void setTicks(String ticks) { 41 | setMember("ticks", ticks); 42 | } 43 | 44 | //#end region 45 | 46 | } 47 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/layout/Layout.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.layout; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | import org.treez.javafxd3.plotly.layout.margin.Margin; 5 | 6 | import org.treez.javafxd3.d3.core.JsEngine; 7 | import org.treez.javafxd3.d3.core.JsObject; 8 | 9 | public class Layout extends JavaScriptObject { 10 | 11 | //#region CONSTRUCTORS 12 | 13 | public Layout(JsEngine engine, JsObject jsObject) { 14 | super(engine,jsObject); 15 | } 16 | 17 | public Layout(JsEngine engine) { 18 | super(engine); 19 | setEmptyObjectAsJsObject(); 20 | } 21 | //#end region 22 | 23 | //#region ACCESSORS 24 | 25 | public void setWidth(double width) { 26 | setMember("width", width); 27 | } 28 | 29 | public void setHeight(double height) { 30 | setMember("height", height); 31 | } 32 | 33 | public void setXAxis(Axis xAxis) { 34 | setMember("xaxis", xAxis.getJsObject()); 35 | } 36 | 37 | public void setYAxis(Axis yAxis) { 38 | setMember("yaxis", yAxis.getJsObject()); 39 | } 40 | 41 | public void setMargin(Margin margin) { 42 | setMember("margin", margin.getJsObject()); 43 | } 44 | 45 | //#end region 46 | 47 | } 48 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/layout/margin/Margin.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.layout.margin; 2 | 3 | import org.treez.javafxd3.d3.wrapper.JavaScriptObject; 4 | 5 | import org.treez.javafxd3.d3.core.JsEngine; 6 | import org.treez.javafxd3.d3.core.JsObject; 7 | 8 | public class Margin extends JavaScriptObject { 9 | 10 | //#region ATTRIBUTES 11 | 12 | 13 | 14 | //#end region 15 | 16 | //#region CONSTRUCTORS 17 | 18 | public Margin(JsEngine engine, JsObject jsObject) { 19 | super(engine,jsObject); 20 | } 21 | 22 | public Margin(JsEngine engine) { 23 | super(engine); 24 | setEmptyObjectAsJsObject(); 25 | } 26 | 27 | //#end region 28 | 29 | //#region ACCESSORS 30 | 31 | public void setL(double l){ 32 | setMember("l", l); 33 | } 34 | 35 | public void setR(double r){ 36 | setMember("r", r); 37 | } 38 | 39 | public void setT(double t){ 40 | setMember("t", t); 41 | } 42 | 43 | public void setB(double b){ 44 | setMember("b", b); 45 | } 46 | 47 | //#end region 48 | 49 | } 50 | -------------------------------------------------------------------------------- /javafx-d3/main/java/org/treez/javafxd3/plotly/layout/margin/ZeroMargin.java: -------------------------------------------------------------------------------- 1 | package org.treez.javafxd3.plotly.layout.margin; 2 | 3 | import org.treez.javafxd3.d3.core.JsEngine; 4 | 5 | public class ZeroMargin extends Margin { 6 | 7 | 8 | //#region CONSTRUCTORS 9 | 10 | public ZeroMargin(JsEngine engine) { 11 | super(engine); 12 | setZeroMargins(); 13 | } 14 | 15 | //#end region 16 | 17 | //#region METHODS 18 | 19 | private void setZeroMargins() { 20 | setMember("l", 0); 21 | setMember("r", 0); 22 | setMember("t", 0); 23 | setMember("b", 0); 24 | } 25 | 26 | //#end region 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /javafx-d3/main/resources/d3-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2010-2016 Mike Bostock 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of contributors may be used to 15 | endorse or promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /javafx-d3/main/resources/dictionary.txt: -------------------------------------------------------------------------------- 1 | accessor 2 | antialiasing 3 | -------------------------------------------------------------------------------- /javafx-d3/main/resources/function-plot-LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2015 MIT © Mauricio Poppe -------------------------------------------------------------------------------- /javafx-d3/main/resources/jquery-LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery JavaScript Library v2.2.4 3 | * http://jquery.com/ 4 | * 5 | * Includes Sizzle.js 6 | * http://sizzlejs.com/ 7 | * 8 | * Copyright jQuery Foundation and other contributors 9 | * Released under the MIT license 10 | * http://jquery.org/license 11 | * 12 | * Date: 2016-05-20T17:23Z 13 | */ -------------------------------------------------------------------------------- /javafx-d3/main/resources/plotly-LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Plotly, Inc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /javafx-d3/main/resources/plotly_js_fiddle.txt: -------------------------------------------------------------------------------- 1 | 2 | https://jsfiddle.net/abalter/0cjprqgy/ 3 | 4 | External Resource: 5 | https://cdn.plot.ly/plotly-latest.min.js 6 | 7 | doc: 8 | https://plot.ly/javascript/contour-plots/ 9 | https://plot.ly/javascript/reference/#contour 10 | 11 | 12 | 13 | var data = [ { 14 | z: [[10, 10.625, 12.5, 15.625, 20], 15 | [5.625, 6.25, 8.125, 11.25, 15.625], 16 | [2.5, 3.125, 5., 8.125, 12.5], 17 | [0.625, 1.25, 3.125, 6.25, 10.625], 18 | [0, 0.625, 2.5, 5.625, 10]], 19 | x: [-9, -6, -5 , -3, -1], 20 | y: [0, 1, 4, 5, 7], 21 | type: 'contour', 22 | 23 | colorscale: 'Jet', 24 | showscale: false, 25 | autocontour: false, 26 | 27 | contours: { 28 | start: 0, 29 | end: 8, 30 | size: 0.4 31 | } 32 | }]; 33 | 34 | var layout = { 35 | margin: { 36 | b: 0, 37 | l: 0, 38 | r: 0, 39 | t: 0 40 | }, 41 | height: 600, 42 | width: 600, 43 | title: '', 44 | xaxis: { 45 | ticks: '', 46 | showticklabels: false , 47 | range: [0,3] 48 | 49 | }, 50 | yaxis: { 51 | ticks: '', 52 | showticklabels: false 53 | } 54 | }; 55 | 56 | Plotly.newPlot('graph', data, layout, {displayModeBar: false}); -------------------------------------------------------------------------------- /javafx-d3/test/java/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | # Except this file 3 | !.gitignore -------------------------------------------------------------------------------- /javafx-d3/test/resources/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | # Except this file 3 | !.gitignore --------------------------------------------------------------------------------