├── .travis.yml ├── LICENSE ├── README.md ├── dist └── jmathplot.jar ├── doc ├── css │ ├── maven-base.css │ ├── maven-theme.css │ ├── print.css │ └── site.css ├── dependencies.html ├── images │ ├── close.gif │ ├── collapsed.gif │ ├── expanded.gif │ ├── external.png │ ├── icon_error_sml.gif │ ├── icon_info_sml.gif │ ├── icon_success_sml.gif │ ├── icon_warning_sml.gif │ ├── logos │ │ ├── build-by-maven-black.png │ │ ├── build-by-maven-white.png │ │ └── maven-feather.png │ └── newwindow.png ├── index.html ├── integration.html ├── issue-tracking.html ├── license.html ├── mail-lists.html ├── plugin-management.html ├── plugins.html ├── project-info.html ├── project-summary.html ├── source-repository.html └── team-list.html ├── examples ├── CommandLineInterface.md ├── CustomPlotExample.md ├── GridPlotsExample.md ├── HistogramExample.md └── LinePlotExample.md ├── pom.xml └── src ├── main ├── java │ └── org │ │ └── math │ │ └── plot │ │ ├── DataPanel.java │ │ ├── DataSelectPanel.java │ │ ├── DataSelectTable.java │ │ ├── FrameView.java │ │ ├── MatrixTablePanel.java │ │ ├── ParametersPanel.java │ │ ├── Plot2DPanel.java │ │ ├── Plot3DPanel.java │ │ ├── PlotPanel.java │ │ ├── canvas │ │ ├── Plot2DCanvas.java │ │ ├── Plot3DCanvas.java │ │ └── PlotCanvas.java │ │ ├── components │ │ ├── DataFrame.java │ │ ├── DataToolBar.java │ │ ├── DatasFrame.java │ │ ├── LegendPanel.java │ │ ├── PlotToolBar.java │ │ └── ScalesFrame.java │ │ ├── plotObjects │ │ ├── Axis.java │ │ ├── Base.java │ │ ├── BaseDependant.java │ │ ├── BaseLabel.java │ │ ├── BaseLine.java │ │ ├── BasePlot.java │ │ ├── Editable.java │ │ ├── Label.java │ │ ├── Line.java │ │ ├── Noteable.java │ │ ├── PaintImage.java │ │ ├── Plotable.java │ │ └── RasterImage.java │ │ ├── plots │ │ ├── BarPlot.java │ │ ├── BoxPlot2D.java │ │ ├── BoxPlot3D.java │ │ ├── CloudPlot2D.java │ │ ├── CloudPlot3D.java │ │ ├── DensityLayerPlot.java │ │ ├── GaussianDensityLayerPlot.java │ │ ├── GridPlot3D.java │ │ ├── HistogramPlot2D.java │ │ ├── HistogramPlot3D.java │ │ ├── LayerPlot.java │ │ ├── LinePlot.java │ │ ├── Plot.java │ │ ├── QuantileLayerPlot.java │ │ ├── ScatterPlot.java │ │ ├── StaircasePlot.java │ │ └── VectorLayerPlot.java │ │ ├── render │ │ ├── AWTDrawer.java │ │ ├── AWTDrawer2D.java │ │ ├── AWTDrawer3D.java │ │ ├── AbstractDrawer.java │ │ ├── Projection.java │ │ ├── Projection2D.java │ │ └── Projection3D.java │ │ └── utils │ │ ├── Array.java │ │ ├── FastMath.java │ │ ├── Histogram.java │ │ └── NumbersUtils.java └── resources │ └── org │ └── math │ └── plot │ └── icons │ ├── adjustbounds.png │ ├── back.png │ ├── center.png │ ├── data.png │ ├── edit.png │ ├── noadjustbounds.png │ ├── position.png │ ├── rotation.png │ ├── scale.png │ ├── toclipboard.png │ ├── tofile.png │ ├── topngfile.png │ └── zoom.png └── test └── resources └── TestApplet.html /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk8 4 | install: mvn install -DskipTests=true -Dgpg.skip=true 5 | script: "mvn cobertura:cobertura" 6 | after_success: 7 | - bash <(curl -s https://codecov.io/bash) 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2021, Yann Richet 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.yannrichet/JMathPlot/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.yannrichet/JMathPlot) 2 | [![Build Status](https://travis-ci.org/yannrichet/jmathplot.png)](https://travis-ci.org/yannrichet/jmathplot) 3 | [![codecov](https://codecov.io/gh/yannrichet/jmathplot/branch/master/graph/badge.svg)](https://codecov.io/gh/yannrichet/jmathplot) 4 | 5 | # JMathPlot: interactive 2D and 3D plots 6 | 7 | Provides interactive 2D/3D plot (without openGL) : 8 | 9 | 2D/3D scatter plot 10 | 2D/3D line plot 11 | 2D staircase plot 12 | 2D/3D histogram plot 13 | 2D/3D boxplot 14 | 3D grid plot 15 | 2D/3D quantiles on plots 16 | 17 | Note: for a true OpenGL java plot library, try the good jzy3d project 18 | 19 | ## Example Java code ## 20 | 21 | ```java 22 | import org.math.plot.*; 23 | ... 24 | 25 | double[] x = ... 26 | double[] y = ... 27 | 28 | // create your PlotPanel (you can use it as a JPanel) 29 | Plot2DPanel plot = new Plot2DPanel(); 30 | 31 | // add a line plot to the PlotPanel 32 | plot.addLinePlot("my plot", x, y); 33 | 34 | // put the PlotPanel in a JFrame, as a JPanel 35 | JFrame frame = new JFrame("a plot panel"); 36 | frame.setContentPane(plot); 37 | frame.setVisible(true); 38 | ``` 39 | 40 | ## Use it ## 41 | 42 | Put https://github.com/yannrichet/jmathplot/blob/master/dist/jmathplot.jar in your java classpath 43 | 44 | Or include maven dependency: 45 | ```xml 46 | 47 | ... 48 | 49 | com.github.yannrichet 50 | JMathPlot 51 | 1.0.1 52 | 53 | ... 54 | 55 | ``` 56 | 57 | Then 58 | - create a new PlotPanel instance: `PlotPanel plot = new Plot2DPanel();` 59 | - add a plot inside `plot.addLinePlot("my plot", x, y);` 60 | - use the PlotPanel as any Swing component (all PlotPanel extends JPanel, in fact) 61 | 62 | ![Analytics](https://ga-beacon.appspot.com/UA-109580-20/jmathplot) 63 | -------------------------------------------------------------------------------- /dist/jmathplot.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/dist/jmathplot.jar -------------------------------------------------------------------------------- /doc/css/maven-base.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0px; 3 | padding: 0px; 4 | } 5 | img { 6 | border:none; 7 | } 8 | table { 9 | padding:0px; 10 | width: 100%; 11 | margin-left: -2px; 12 | margin-right: -2px; 13 | } 14 | acronym { 15 | cursor: help; 16 | border-bottom: 1px dotted #feb; 17 | } 18 | table.bodyTable th, table.bodyTable td { 19 | padding: 2px 4px 2px 4px; 20 | vertical-align: top; 21 | } 22 | div.clear{ 23 | clear:both; 24 | visibility: hidden; 25 | } 26 | div.clear hr{ 27 | display: none; 28 | } 29 | #bannerLeft, #bannerRight { 30 | font-size: xx-large; 31 | font-weight: bold; 32 | } 33 | #bannerLeft img, #bannerRight img { 34 | margin: 0px; 35 | } 36 | .xleft, #bannerLeft img { 37 | float:left; 38 | } 39 | .xright, #bannerRight { 40 | float:right; 41 | } 42 | #banner { 43 | padding: 0px; 44 | } 45 | #banner img { 46 | border: none; 47 | } 48 | #breadcrumbs { 49 | padding: 3px 10px 3px 10px; 50 | } 51 | #leftColumn { 52 | width: 170px; 53 | float:left; 54 | overflow: auto; 55 | } 56 | #bodyColumn { 57 | margin-right: 1.5em; 58 | margin-left: 197px; 59 | } 60 | #legend { 61 | padding: 8px 0 8px 0; 62 | } 63 | #navcolumn { 64 | padding: 8px 4px 0 8px; 65 | } 66 | #navcolumn h5 { 67 | margin: 0; 68 | padding: 0; 69 | font-size: small; 70 | } 71 | #navcolumn ul { 72 | margin: 0; 73 | padding: 0; 74 | font-size: small; 75 | } 76 | #navcolumn li { 77 | list-style-type: none; 78 | background-image: none; 79 | background-repeat: no-repeat; 80 | background-position: 0 0.4em; 81 | padding-left: 16px; 82 | list-style-position: outside; 83 | line-height: 1.2em; 84 | font-size: smaller; 85 | } 86 | #navcolumn li.expanded { 87 | background-image: url(../images/expanded.gif); 88 | } 89 | #navcolumn li.collapsed { 90 | background-image: url(../images/collapsed.gif); 91 | } 92 | #poweredBy { 93 | text-align: center; 94 | } 95 | #navcolumn img { 96 | margin-top: 10px; 97 | margin-bottom: 3px; 98 | } 99 | #poweredBy img { 100 | display:block; 101 | margin: 20px 0 20px 17px; 102 | } 103 | #search img { 104 | margin: 0px; 105 | display: block; 106 | } 107 | #search #q, #search #btnG { 108 | border: 1px solid #999; 109 | margin-bottom:10px; 110 | } 111 | #search form { 112 | margin: 0px; 113 | } 114 | #lastPublished { 115 | font-size: x-small; 116 | } 117 | .navSection { 118 | margin-bottom: 2px; 119 | padding: 8px; 120 | } 121 | .navSectionHead { 122 | font-weight: bold; 123 | font-size: x-small; 124 | } 125 | .section { 126 | padding: 4px; 127 | } 128 | #footer { 129 | padding: 3px 10px 3px 10px; 130 | font-size: x-small; 131 | } 132 | #breadcrumbs { 133 | font-size: x-small; 134 | margin: 0pt; 135 | } 136 | .source { 137 | padding: 12px; 138 | margin: 1em 7px 1em 7px; 139 | } 140 | .source pre { 141 | margin: 0px; 142 | padding: 0px; 143 | } 144 | #navcolumn img.imageLink, .imageLink { 145 | padding-left: 0px; 146 | padding-bottom: 0px; 147 | padding-top: 0px; 148 | padding-right: 2px; 149 | border: 0px; 150 | margin: 0px; 151 | } 152 | -------------------------------------------------------------------------------- /doc/css/maven-theme.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | body { 21 | padding: 0px 0px 10px 0px; 22 | } 23 | body, td, select, input, li{ 24 | font-family: Verdana, Helvetica, Arial, sans-serif; 25 | font-size: 13px; 26 | } 27 | code{ 28 | font-family: Courier, monospace; 29 | font-size: 13px; 30 | } 31 | a { 32 | text-decoration: none; 33 | } 34 | a:link { 35 | color:#36a; 36 | } 37 | a:visited { 38 | color:#47a; 39 | } 40 | a:active, a:hover { 41 | color:#69c; 42 | } 43 | #legend li.externalLink { 44 | background: url(../images/external.png) left top no-repeat; 45 | padding-left: 18px; 46 | } 47 | a.externalLink, a.externalLink:link, a.externalLink:visited, a.externalLink:active, a.externalLink:hover { 48 | background: url(../images/external.png) right center no-repeat; 49 | padding-right: 18px; 50 | } 51 | #legend li.newWindow { 52 | background: url(../images/newwindow.png) left top no-repeat; 53 | padding-left: 18px; 54 | } 55 | a.newWindow, a.newWindow:link, a.newWindow:visited, a.newWindow:active, a.newWindow:hover { 56 | background: url(../images/newwindow.png) right center no-repeat; 57 | padding-right: 18px; 58 | } 59 | h2 { 60 | padding: 4px 4px 4px 6px; 61 | border: 1px solid #999; 62 | color: #900; 63 | background-color: #ddd; 64 | font-weight:900; 65 | font-size: x-large; 66 | } 67 | h3 { 68 | padding: 4px 4px 4px 6px; 69 | border: 1px solid #aaa; 70 | color: #900; 71 | background-color: #eee; 72 | font-weight: normal; 73 | font-size: large; 74 | } 75 | h4 { 76 | padding: 4px 4px 4px 6px; 77 | border: 1px solid #bbb; 78 | color: #900; 79 | background-color: #fff; 80 | font-weight: normal; 81 | font-size: large; 82 | } 83 | h5 { 84 | padding: 4px 4px 4px 6px; 85 | color: #900; 86 | font-size: medium; 87 | } 88 | p { 89 | line-height: 1.3em; 90 | font-size: small; 91 | } 92 | #breadcrumbs { 93 | border-top: 1px solid #aaa; 94 | border-bottom: 1px solid #aaa; 95 | background-color: #ccc; 96 | } 97 | #leftColumn { 98 | margin: 10px 0 0 5px; 99 | border: 1px solid #999; 100 | background-color: #eee; 101 | padding-bottom: 3px; /* IE-9 scrollbar-fix */ 102 | } 103 | #navcolumn h5 { 104 | font-size: smaller; 105 | border-bottom: 1px solid #aaaaaa; 106 | padding-top: 2px; 107 | color: #000; 108 | } 109 | 110 | table.bodyTable th { 111 | color: white; 112 | background-color: #bbb; 113 | text-align: left; 114 | font-weight: bold; 115 | } 116 | 117 | table.bodyTable th, table.bodyTable td { 118 | font-size: 1em; 119 | } 120 | 121 | table.bodyTable tr.a { 122 | background-color: #ddd; 123 | } 124 | 125 | table.bodyTable tr.b { 126 | background-color: #eee; 127 | } 128 | 129 | .source { 130 | border: 1px solid #999; 131 | } 132 | dl { 133 | padding: 4px 4px 4px 6px; 134 | border: 1px solid #aaa; 135 | background-color: #ffc; 136 | } 137 | dt { 138 | color: #900; 139 | } 140 | #organizationLogo img, #projectLogo img, #projectLogo span{ 141 | margin: 8px; 142 | } 143 | #banner { 144 | border-bottom: 1px solid #fff; 145 | } 146 | .errormark, .warningmark, .donemark, .infomark { 147 | background: url(../images/icon_error_sml.gif) no-repeat; 148 | } 149 | 150 | .warningmark { 151 | background-image: url(../images/icon_warning_sml.gif); 152 | } 153 | 154 | .donemark { 155 | background-image: url(../images/icon_success_sml.gif); 156 | } 157 | 158 | .infomark { 159 | background-image: url(../images/icon_info_sml.gif); 160 | } 161 | 162 | -------------------------------------------------------------------------------- /doc/css/print.css: -------------------------------------------------------------------------------- 1 | #banner, #footer, #leftcol, #breadcrumbs, .docs #toc, .docs .courtesylinks, #leftColumn, #navColumn { 2 | display: none !important; 3 | } 4 | #bodyColumn, body.docs div.docs { 5 | margin: 0 !important; 6 | border: none !important 7 | } 8 | -------------------------------------------------------------------------------- /doc/css/site.css: -------------------------------------------------------------------------------- 1 | /* You can override this file with your own styles */ -------------------------------------------------------------------------------- /doc/images/close.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/close.gif -------------------------------------------------------------------------------- /doc/images/collapsed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/collapsed.gif -------------------------------------------------------------------------------- /doc/images/expanded.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/expanded.gif -------------------------------------------------------------------------------- /doc/images/external.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/external.png -------------------------------------------------------------------------------- /doc/images/icon_error_sml.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/icon_error_sml.gif -------------------------------------------------------------------------------- /doc/images/icon_info_sml.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/icon_info_sml.gif -------------------------------------------------------------------------------- /doc/images/icon_success_sml.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/icon_success_sml.gif -------------------------------------------------------------------------------- /doc/images/icon_warning_sml.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/icon_warning_sml.gif -------------------------------------------------------------------------------- /doc/images/logos/build-by-maven-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/logos/build-by-maven-black.png -------------------------------------------------------------------------------- /doc/images/logos/build-by-maven-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/logos/build-by-maven-white.png -------------------------------------------------------------------------------- /doc/images/logos/maven-feather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/logos/maven-feather.png -------------------------------------------------------------------------------- /doc/images/newwindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/doc/images/newwindow.png -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - About 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

About jmathplot

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

54 |
55 |
56 |
57 |
58 |
59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/integration.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - Continuous Integration 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

Continuous Integration

No continuous integration management system is defined. Please check back at a later date.

54 |
55 |
56 |
57 |
58 |
59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/issue-tracking.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - Issue Tracking 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

Issue Tracking

No issue management system is defined. Please check back at a later date.

54 |
55 |
56 |
57 |
58 |
59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/license.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - Project License 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

Project License

No project license is defined for this project.

54 |
55 |
56 |
57 |
58 |
59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/mail-lists.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - Project Mailing Lists 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

Project Mailing Lists

There are no mailing lists currently associated with this project.

54 |
55 |
56 |
57 |
58 |
59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/plugin-management.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - Project Plugin Management 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

Project Plugin Management

GroupIdArtifactIdVersion
org.apache.maven.pluginsmaven-antrun-plugin1.7
org.apache.maven.pluginsmaven-assembly-plugin2.2-beta-4
org.apache.maven.pluginsmaven-clean-plugin2.5
org.apache.maven.pluginsmaven-compiler-plugin2.5.1
org.apache.maven.pluginsmaven-dependency-plugin2.4
org.apache.maven.pluginsmaven-deploy-plugin2.4
org.apache.maven.pluginsmaven-ear-plugin2.3.2
org.apache.maven.pluginsmaven-ejb-plugin2.2
org.apache.maven.pluginsmaven-install-plugin2.4
org.apache.maven.pluginsmaven-jar-plugin2.3.2
org.apache.maven.pluginsmaven-javadoc-plugin2.9.1
org.apache.maven.pluginsmaven-plugin-plugin3.2
org.apache.maven.pluginsmaven-rar-plugin2.2
org.apache.maven.pluginsmaven-release-plugin2.1
org.apache.maven.pluginsmaven-resources-plugin2.3
org.apache.maven.pluginsmaven-site-plugin2.1
org.apache.maven.pluginsmaven-source-plugin2.2.1
org.apache.maven.pluginsmaven-surefire-plugin2.10
org.apache.maven.pluginsmaven-war-plugin2.1.1
54 |
55 |
56 |
57 |
58 |
59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/plugins.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - Project Build Plugins 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

Project Build Plugins

GroupIdArtifactIdVersion
org.apache.maven.pluginsmaven-compiler-plugin2.5.1
org.apache.maven.pluginsmaven-enforcer-plugin1.2
org.apache.maven.pluginsmaven-install-plugin2.5.2
org.apache.maven.pluginsmaven-jar-plugin2.5
org.apache.maven.pluginsmaven-release-plugin2.4.2

Project Report Plugins

There are no plugins reports defined in the Reporting part of this project.

54 |
55 |
56 |
57 |
58 |
59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/project-info.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - Project Information 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

Project Information

This document provides an overview of the various documents and links that are part of this project's general information. All of this content is automatically generated by Maven on behalf of the project.

Overview

DocumentDescription
Project LicenseThis is a link to the definitions of project licenses.
Mailing ListsThis document provides subscription and archive information for this project's mailing lists.
Plugin ManagementThis document lists the plugins that are defined through pluginManagement.
Project PluginsThis document lists the build plugins and the report plugins used by this project.
Continuous IntegrationThis is a link to the definitions of all continuous integration processes that builds and tests code on a frequent, regular basis.
Source RepositoryThis is a link to the online source repository that can be viewed via a web browser.
AboutSonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Issue TrackingThis is a link to the issue management system for this project. Issues (bugs, features, change requests) can be created and queried using this link.
Project TeamThis document provides information on the members of this project. These are the individuals who have contributed to the project in one form or another.
Project SummaryThis document lists other related information of this project
DependenciesThis document lists the project's dependencies and provides information on each dependency.
54 |
55 |
56 |
57 |
58 |
59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/project-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - Project Summary 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

Project Summary

Project Information

FieldValue
Namejmathplot
DescriptionSonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Homepagehttps://github.com/yannrichet/jmathplot

Project Organization

This project does not belong to an organization.

Build Information

FieldValue
GroupIdcom.github.yannrichet
ArtifactIdJMathPlot
Version1.0
Typejar
54 |
55 |
56 |
57 |
58 |
59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/source-repository.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - Source Repository 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

Overview

This project uses a Source Content Management System to manage its source code.

Web Access

The following is a link to the online source repository.

Anonymous access

Refer to the documentation of the SCM used for more information about anonymously check out. The connection url is:

git:git@github.com:yannrichet/jmathplot.git

Developer access

Refer to the documentation of the SCM used for more information about developer check out. The connection url is:

git:git@github.com:yannrichet/jmathplot.git

Access from behind a firewall

Refer to the documentation of the SCM used for more information about access behind a firewall.

54 |
55 |
56 |
57 |
58 |
59 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/team-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jmathplot - Team list 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 40 |
41 | 50 |
51 |
52 |
53 |

The Team

A successful project requires many people to play many roles. Some members write code or documentation, while others are valuable as testers, submitting patches and suggestions.

The team is comprised of Members and Contributors. Members have direct access to the source of a project and actively evolve the code-base. Contributors improve the project through submission of patches and suggestions to the Members. The number of Contributors to the project is unbounded. Get involved today. All contributions to the project are greatly appreciated.

Members

There are no developers working on this project.

Contributors

There are no contributors listed for this project. Please check back again later.

69 |
70 |
71 |
72 |
73 |
74 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /examples/CommandLineInterface.md: -------------------------------------------------------------------------------- 1 | ## Shell ## 2 | 3 | You can use JMathPlot in CLI to plot the content of ASCII files (same way that XMGrace). You just need to get jplot.sh for Linux/MacOS/Solaris or jplot.bat for Windows, and jmathplot.jar in the same directory. 4 | 5 | ``` 6 | Usage: jplot. <-2D|-3D> [-l ] [options] [[options] other ASCII file] 7 | [-l ] giving the legend position 8 | [options] are: 9 | -t )|HISTOGRAM3D(,)|GRID3D|CLOUD2D(,)|CLOUD3D(,,)> type of the plot 10 | SCATTER|LINE|BAR: each line of the ASCII file contains coordinates of one point. 11 | HISTOGRAM2D(): ASCII file contains the 1D sample (i.e. m=1) to split in h slices. 12 | HISTOGRAM3D(,): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis). 13 | GRID3D: ASCII file is a matrix, first row gives n X grid values, first column gives m Y grid values, other values are Z values. 14 | CLOUD2D(,): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis), density of cloud corresponds to frequency of X-Y slice in given 2D sample. 15 | CLOUD3D(,,): ASCII file contains the 3D sample (i.e. m=3) to split in h*k*l slices (h slices on X axis, k slices on Y axis, l slices on Y axis), density of cloud corresponds to frequency of X-Y-Z slice in given 3D sample. 16 | -n name name of the plot 17 | -v vector data to add to the plot 18 | -q() Q-quantile to add to the plot on axis. Each line of the given ASCII file contains the value of quantile for probvability Q. 19 | -qP p-quantiles density to add to the plot on axis. Each line of the given ASCII file contains p values. 20 | -qN Gaussian density to add to the plot on axis. Each line of the given ASCII file contains a standard deviation. 21 | ``` 22 | 23 | Example: jplot. -3D -l SOUTH -t SCATTER tmp.dat 24 | 25 | ## Python ## 26 | 27 | You can use JMathPlot in Python to plot arrays (same way that matplotlib). You need to use jplot.py script which provides an interface to CLI call with similar syntax. 28 | ``` 29 | Usage : jplot2d(data1,options,data2,options) or jplot3d(data1,options,data2,options) [data] is an array of numbers, [options] are related to previous [data] and should be : 30 | 31 | -t )|HISTOGRAM3D(,)|GRID3D|CLOUD2D(,)|CLOUD3D(,,)> type of the plot 32 | SCATTER|LINE|BAR: each line of the ASCII file contains coordinates of one point. 33 | HISTOGRAM2D(): ASCII file contains the 1D sample (i.e. m=1) to split in h slices. 34 | HISTOGRAM3D(,): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis). 35 | GRID3D: ASCII file is a matrix, first row gives n X grid values, first column gives m Y grid values, other values are Z values. 36 | CLOUD2D(,): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis), density of cloud corresponds to frequency of X-Y slice in given 2D sample. 37 | CLOUD3D(,,): ASCII file contains the 3D sample (i.e. m=3) to split in h*k*l slices (h slices on X axis, k slices on Y axis, l slices on Y axis), density of cloud corresponds to frequency of X-Y-Z slice in given 3D sample. 38 | -n name name of the plot 39 | -v vector data to add to the plot 40 | -q() Q-quantile to add to the plot on axis. Each line of the given ASCII file contains the value of quantile for probvability Q. 41 | -qP p-quantiles density to add to the plot on axis. Each line of the given ASCII file contains p values. 42 | -qN Gaussian density to add to the plot on axis. Each line of the given ASCII file contains a standard deviation. 43 | ``` 44 | 45 | ## Scilab ## 46 | You can use JMathPlot in Scilab to plot arrays (same way that plot2d or plot3d). You need to use jplot.sci script which provides an interface to CLI call with similar syntax. 47 | ``` 48 | Usage : jplot2d(data1,options,data2,options) or jplot3d(data1,options,data2,options) [data] is an array of numbers, [options] are related to previous [data] and should be : 49 | 50 | -t )|HISTOGRAM3D(,)|GRID3D|CLOUD2D(,)|CLOUD3D(,,)> type of the plot 51 | SCATTER|LINE|BAR: each line of the ASCII file contains coordinates of one point. 52 | HISTOGRAM2D(): ASCII file contains the 1D sample (i.e. m=1) to split in h slices. 53 | HISTOGRAM3D(,): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis). 54 | GRID3D: ASCII file is a matrix, first row gives n X grid values, first column gives m Y grid values, other values are Z values. 55 | CLOUD2D(,): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis), density of cloud corresponds to frequency of X-Y slice in given 2D sample. 56 | CLOUD3D(,,): ASCII file contains the 3D sample (i.e. m=3) to split in h*k*l slices (h slices on X axis, k slices on Y axis, l slices on Y axis), density of cloud corresponds to frequency of X-Y-Z slice in given 3D sample. 57 | -n name name of the plot 58 | -v vector data to add to the plot 59 | -q() Q-quantile to add to the plot on axis. Each line of the given ASCII file contains the value of quantile for probvability Q. 60 | -qP p-quantiles density to add to the plot on axis. Each line of the given ASCII file contains p values. 61 | -qN Gaussian density to add to the plot on axis. Each line of the given ASCII file contains a standard deviation. 62 | ``` 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /examples/CustomPlotExample.md: -------------------------------------------------------------------------------- 1 | ```java 2 | 3 | 4 | 5 | import java.awt.*; 6 | 7 | import javax.swing.*; 8 | 9 | import org.math.plot.*; 10 | import org.math.plot.plotObjects.*; 11 | 12 | import static java.lang.Math.*; 13 | 14 | import static org.math.array.StatisticSample.*; 15 | 16 | public class CustomPlotExample { 17 | public static void main(String[] args) { 18 | 19 | // define your data 20 | double[] x = randomNormal(1000, 0, 1); // 1000 random numbers from a normal (Gaussian) statistical law 21 | double[] y = randomUniform(1000, -3, 3); // 1000 random numbers from a uniform statistical law 22 | 23 | // create your PlotPanel (you can use it as a JPanel) 24 | Plot2DPanel plot = new Plot2DPanel(); 25 | 26 | // legend at SOUTH 27 | plot.addLegend("SOUTH"); 28 | 29 | // add the histogram (50 slices) of x to the PlotPanel 30 | plot.addHistogramPlot("Gaussian population", x, 50); 31 | 32 | // add the histogram (50 slices) of y to the PlotPanel in GREEN 33 | plot.addHistogramPlot("Uniform population", Color.RED, y, 50); 34 | 35 | // add a title 36 | BaseLabel title = new BaseLabel("...My nice plot...", Color.RED, 0.5, 1.1); 37 | title.setFont(new Font("Courier", Font.BOLD, 20)); 38 | plot.addPlotable(title); 39 | 40 | // change name of axes 41 | plot.setAxesLabels("", "frequency"); 42 | 43 | // customize X axe 44 | // rotate light labels 45 | plot.getAxe(0).setLightLabelAngle(-PI / 4); 46 | // change axe title position relatively to the base of the plot 47 | plot.getAxe(0).setLabelPosition(0.5, -0.15); 48 | 49 | // customize Y axe 50 | // rotate light labels 51 | plot.getAxe(1).setLightLabelAngle(-PI / 4); 52 | // change axe title position relatively to the base of the plot 53 | plot.getAxe(1).setLabelPosition(-0.15, 0.5); 54 | // change axe title angle 55 | plot.getAxe(1).setLabelAngle(-PI / 2); 56 | 57 | // put the PlotPanel in a JFrame like a JPanel 58 | JFrame frame = new JFrame("a plot panel"); 59 | frame.setSize(600, 600); 60 | frame.setContentPane(plot); 61 | frame.setVisible(true); 62 | 63 | } 64 | } 65 | 66 | 67 | 68 | ``` 69 | -------------------------------------------------------------------------------- /examples/GridPlotsExample.md: -------------------------------------------------------------------------------- 1 | ```java 2 | 3 | import javax.swing.*; 4 | 5 | import org.math.plot.*; 6 | 7 | import static java.lang.Math.*; 8 | 9 | import static org.math.array.DoubleArray.*; 10 | 11 | public class GridPlotsExample { 12 | public static void main(String[] args) { 13 | 14 | // define your data 15 | double[] x = increment(0.0, 0.1, 1.0); // x = 0.0:0.1:1.0 16 | double[] y = increment(0.0, 0.05, 1.0);// y = 0.0:0.05:1.0 17 | double[][] z1 = f1(x, y); 18 | double[][] z2 = f2(x, y); 19 | 20 | // create your PlotPanel (you can use it as a JPanel) with a legend at SOUTH 21 | Plot3DPanel plot = new Plot3DPanel("SOUTH"); 22 | 23 | // add grid plot to the PlotPanel 24 | plot.addGridPlot("z=cos(PI*x)*sin(PI*y)", x, y, z1); 25 | plot.addGridPlot("z=sin(PI*x)*cos(PI*y)", x, y, z2); 26 | 27 | // put the PlotPanel in a JFrame like a JPanel 28 | JFrame frame = new JFrame("a plot panel"); 29 | frame.setSize(600, 600); 30 | frame.setContentPane(plot); 31 | frame.setVisible(true); 32 | 33 | } 34 | 35 | // function definition: z=cos(PI*x)*sin(PI*y) 36 | public static double f1(double x, double y) { 37 | double z = cos(x * PI) * sin(y * PI); 38 | return z; 39 | } 40 | 41 | // grid version of the function 42 | public static double[][] f1(double[] x, double[] y) { 43 | double[][] z = new double[y.length][x.length]; 44 | for (int i = 0; i < x.length; i++) 45 | for (int j = 0; j < y.length; j++) 46 | z[j][i] = f1(x[i], y[j]); 47 | return z; 48 | } 49 | 50 | // another function definition: z=sin(PI*x)*cos(PI*y) 51 | public static double f2(double x, double y) { 52 | double z = sin(x * PI) * cos(y * PI); 53 | return z; 54 | } 55 | 56 | // grid version of the function 57 | public static double[][] f2(double[] x, double[] y) { 58 | double[][] z = new double[y.length][x.length]; 59 | for (int i = 0; i < x.length; i++) 60 | for (int j = 0; j < y.length; j++) 61 | z[j][i] = f2(x[i], y[j]); 62 | return z; 63 | } 64 | } 65 | 66 | ``` 67 | -------------------------------------------------------------------------------- /examples/HistogramExample.md: -------------------------------------------------------------------------------- 1 | ```java 2 | 3 | import javax.swing.*; 4 | 5 | import org.math.plot.*; 6 | 7 | import static org.math.array.StatisticSample.*; 8 | 9 | public class HistogramExample { 10 | public static void main(String[] args) { 11 | 12 | // define your data 13 | double[] x = randomLogNormal(1000, 0, 0.5); // 1000 random numbers from a log normal statistical law 14 | 15 | // create your PlotPanel (you can use it as a JPanel) 16 | Plot2DPanel plot = new Plot2DPanel(); 17 | 18 | // add the histogram (50 slices) of x to the PlotPanel 19 | plot.addHistogramPlot("Log Normal population", x, 50); 20 | 21 | // put the PlotPanel in a JFrame like a JPanel 22 | JFrame frame = new JFrame("a plot panel"); 23 | frame.setSize(600, 600); 24 | frame.setContentPane(plot); 25 | frame.setVisible(true); 26 | 27 | } 28 | } 29 | 30 | ``` 31 | -------------------------------------------------------------------------------- /examples/LinePlotExample.md: -------------------------------------------------------------------------------- 1 | ```java 2 | 3 | 4 | import javax.swing.*; 5 | 6 | import org.math.plot.*; 7 | 8 | public class LinePlotExample { 9 | public static void main(String[] args) { 10 | 11 | // define your data 12 | double[] x = { 1, 2, 3, 4, 5, 6 }; 13 | double[] y = { 45, 89, 6, 32, 63, 12 }; 14 | 15 | // create your PlotPanel (you can use it as a JPanel) 16 | Plot2DPanel plot = new Plot2DPanel(); 17 | 18 | // define the legend position 19 | plot.addLegend("SOUTH"); 20 | 21 | // add a line plot to the PlotPanel 22 | plot.addLinePlot("my plot", x, y); 23 | 24 | // put the PlotPanel in a JFrame like a JPanel 25 | JFrame frame = new JFrame("a plot panel"); 26 | frame.setSize(600, 600); 27 | frame.setContentPane(plot); 28 | frame.setVisible(true); 29 | 30 | } 31 | } 32 | 33 | 34 | ``` 35 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.sonatype.oss 4 | oss-parent 5 | 9 6 | 7 | 8 | 4.0.0 9 | 10 | com.github.yannrichet 11 | JMathPlot 12 | 1.0.1 13 | jar 14 | jmathplot 15 | 16 | https://github.com/yannrichet/jmathplot 17 | 18 | 19 | 20 | 21 | 22 | 23 | com.github.yannrichet 24 | JMathIO 25 | 1.0 26 | 27 | 28 | com.github.yannrichet 29 | JMathArray 30 | 1.0 31 | 32 | 33 | 34 | 35 | 36 | sonatype-oss-releases 37 | https://oss.sonatype.org/content/repositories/releases 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-compiler-plugin 46 | 47 | 1.6 48 | 1.6 49 | 50 | 51 | 52 | org.apache.maven.plugins 53 | maven-jar-plugin 54 | 2.5 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-install-plugin 59 | 2.5.2 60 | 61 | 62 | org.apache.maven.plugins 63 | maven-release-plugin 64 | 2.4.2 65 | 66 | 67 | org.apache.maven.plugins 68 | maven-source-plugin 69 | 2.2.1 70 | 71 | 72 | attach-sources 73 | 74 | jar-no-fork 75 | 76 | 77 | 78 | 79 | 80 | org.apache.maven.plugins 81 | maven-javadoc-plugin 82 | 2.9.1 83 | 84 | 85 | attach-javadocs 86 | 87 | jar 88 | 89 | 90 | 91 | 92 | 93 | org.apache.maven.plugins 94 | maven-gpg-plugin 95 | 1.5 96 | 97 | 98 | sign-artifacts 99 | verify 100 | 101 | sign 102 | 103 | 104 | 105 | 106 | 107 | org.sonatype.plugins 108 | nexus-staging-maven-plugin 109 | 1.6.3 110 | true 111 | 112 | ossrh 113 | https://oss.sonatype.org/ 114 | true 115 | 116 | 117 | 118 | org.codehaus.mojo 119 | cobertura-maven-plugin 120 | 2.7 121 | 122 | 123 | html 124 | xml 125 | 126 | 127 | 128 | 129 | 130 | jmathplot 131 | 132 | 133 | 134 | scm:git:git@github.com:yannrichet/jmathplot.git 135 | scm:git:git@github.com:yannrichet/jmathplot.git 136 | git@github.com:yannrichet/jmathplot.git 137 | 138 | 139 | 140 | 141 | ossrh 142 | https://oss.sonatype.org/content/repositories/snapshots 143 | 144 | 145 | ossrh 146 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/DataPanel.java: -------------------------------------------------------------------------------- 1 | package org.math.plot; 2 | 3 | import java.awt.*; 4 | import java.awt.event.*; 5 | import java.io.*; 6 | 7 | import javax.swing.*; 8 | 9 | import org.math.io.*; 10 | import org.math.plot.components.*; 11 | 12 | /** 13 | * BSD License 14 | * 15 | * @author Yann RICHET 16 | */ 17 | public abstract class DataPanel extends JPanel implements ComponentListener, FilePrintable, ClipBoardPrintable, StringPrintable { 18 | 19 | protected DataToolBar toolBar; 20 | protected JScrollPane scrollPane; 21 | public static int[] dimension = new int[]{400, 400}; 22 | 23 | public DataPanel() { 24 | setLayout(new BorderLayout()); 25 | initToolBar(); 26 | init(); 27 | } 28 | 29 | protected void initToolBar() { 30 | toolBar = new DataToolBar(this); 31 | add(toolBar, BorderLayout.NORTH); 32 | toolBar.setFloatable(false); 33 | } 34 | 35 | protected void initSize() { 36 | if (scrollPane != null) { 37 | scrollPane.setSize(this.getSize()); 38 | } 39 | // scrollPane.setPreferredSize(this.getSize()); 40 | } 41 | 42 | protected void init() { 43 | // initSize(); 44 | addComponentListener(this); 45 | } 46 | 47 | public void update() { 48 | // this.remove(scrollPane); 49 | toWindow(); 50 | repaint(); 51 | } 52 | 53 | protected abstract void toWindow(); 54 | 55 | public abstract void toClipBoard(); 56 | 57 | public abstract void toASCIIFile(File file); 58 | 59 | public void componentHidden(ComponentEvent e) { 60 | } 61 | 62 | public void componentMoved(ComponentEvent e) { 63 | } 64 | 65 | public void componentResized(ComponentEvent e) { 66 | /* 67 | * dimension = new int[] { (int) (this.getSize().getWidth()), (int) 68 | * (this.getSize().getHeight()) }; 69 | */ 70 | initSize(); 71 | } 72 | 73 | public void componentShown(ComponentEvent e) { 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/FrameView.java: -------------------------------------------------------------------------------- 1 | package org.math.plot; 2 | 3 | import javax.swing.*; 4 | 5 | import org.math.plot.canvas.*; 6 | 7 | /** 8 | * BSD License 9 | * 10 | * @author Yann RICHET 11 | */ 12 | public class FrameView extends JFrame { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | public FrameView(Plot2DCanvas... canvas) { 17 | JPanel panel = new JPanel(); 18 | for (int i = 0; i < canvas.length; i++) 19 | panel.add(new Plot2DPanel(canvas[i])); 20 | setContentPane(panel); 21 | pack(); 22 | setSize(600,600); 23 | setVisible(true); 24 | } 25 | 26 | public FrameView(Plot3DCanvas... canvas) { 27 | JPanel panel = new JPanel(); 28 | for (int i = 0; i < canvas.length; i++) 29 | panel.add(new Plot3DPanel(canvas[i])); 30 | setContentPane(panel); 31 | pack(); 32 | setSize(600,600); 33 | setVisible(true); 34 | } 35 | 36 | public FrameView(String title, JComponent panel) { 37 | super(title); 38 | setContentPane(panel); 39 | pack(); 40 | setSize(600,600); 41 | setVisible(true); 42 | } 43 | 44 | public FrameView(JComponent... panels) { 45 | JPanel panel = new JPanel(); 46 | for (int i = 0; i < panels.length; i++) 47 | panel.add(panels[i]); 48 | setContentPane(panel); 49 | pack(); 50 | setSize(600,600); 51 | setVisible(true); 52 | } 53 | 54 | public FrameView(JPanel panel) { 55 | setContentPane(panel); 56 | pack(); 57 | setSize(600,600); 58 | setVisible(true); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/MatrixTablePanel.java: -------------------------------------------------------------------------------- 1 | package org.math.plot; 2 | 3 | import java.awt.*; 4 | import java.awt.datatransfer.*; 5 | import java.io.*; 6 | 7 | import javax.swing.*; 8 | import javax.swing.event.ListSelectionListener; 9 | import javax.swing.table.*; 10 | 11 | import org.math.io.files.*; 12 | import org.math.plot.utils.*; 13 | 14 | /** 15 | * BSD License 16 | * 17 | * @author Yann RICHET 18 | */ 19 | public class MatrixTablePanel extends DataPanel { 20 | 21 | private static final long serialVersionUID = 1L; 22 | private JTable table; 23 | private TableModel model; 24 | private Object[][] M; 25 | private boolean viewHeaders = false; 26 | private String[] headers; 27 | 28 | public MatrixTablePanel(Object[][] m) { 29 | this(m, null); 30 | } 31 | 32 | public MatrixTablePanel(Object[][] m, String[] headers) { 33 | super(); 34 | M = m; 35 | if (headers == null) { 36 | if (M.length == 0) { 37 | this.headers = new String[0]; 38 | } else { 39 | this.headers = new String[M[0].length]; 40 | } 41 | } else { 42 | viewHeaders = true; 43 | this.headers = headers; 44 | } 45 | setModel(); 46 | toWindow(); 47 | } 48 | 49 | public void addSelectionListener(ListSelectionListener lsitener) { 50 | ListSelectionModel listSelectionModel = table.getSelectionModel(); 51 | listSelectionModel.addListSelectionListener(lsitener); 52 | } 53 | 54 | public void removeSelectionListener(ListSelectionListener lsitener) { 55 | ListSelectionModel listSelectionModel = table.getSelectionModel(); 56 | listSelectionModel.removeListSelectionListener(lsitener); 57 | } 58 | 59 | public void toClipBoard() { 60 | try { 61 | Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(Array.cat(M)), null); 62 | } catch (IllegalStateException e) { 63 | JOptionPane.showConfirmDialog(null, "Copy to clipboard failed : " + e.getMessage(), "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); 64 | } 65 | } 66 | 67 | public String getText() { 68 | return M.toString(); 69 | } 70 | 71 | public void toASCIIFile(File file) { 72 | try { 73 | ASCIIFile.write(file, Array.cat(M)); 74 | } catch (NullPointerException e) { 75 | // System.out.println("File not saved"); 76 | } 77 | } 78 | 79 | private void setModel() { 80 | /*Double[][] array = null; 81 | if (M.length != 0) { 82 | array = new Double[M.length][M[0].length]; 83 | for (int i = 0; i < array.length; i++) { 84 | for (int j = 0; j < array[i].length; j++) { 85 | array[i][j] = new Double(M[i][j]); 86 | } 87 | } 88 | } else 89 | array = new Double[0][0];*/ 90 | 91 | model = new DefaultTableModel(M, headers) { 92 | 93 | private static final long serialVersionUID = 1L; 94 | 95 | @Override 96 | public boolean isCellEditable(int row, int column) { 97 | return false; 98 | } 99 | }; 100 | 101 | } 102 | 103 | public void setHeaders(String[] h) { 104 | if (M.length != 0) { 105 | if (h.length != M[0].length) { 106 | throw new IllegalArgumentException("Headers of the table must have " + M[0].length + " elements."); 107 | } 108 | } 109 | 110 | headers = h; 111 | viewHeaders = true; 112 | update(); 113 | } 114 | 115 | public void update() { 116 | setModel(); 117 | super.update(); 118 | } 119 | 120 | public void setMatrix(Object[][] m) { 121 | M = m; 122 | 123 | if (M.length == 0) { 124 | headers = new String[0]; 125 | } else { 126 | headers = new String[M[0].length]; 127 | } 128 | 129 | update(); 130 | } 131 | 132 | public void toWindow() { 133 | table = new JTable(model); 134 | 135 | if (!viewHeaders) { 136 | table.setTableHeader(null); 137 | } 138 | 139 | table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); 140 | table.setRowSelectionAllowed(true); 141 | table.setEnabled(true); 142 | 143 | scrollPane = new JScrollPane(table); 144 | 145 | /* 146 | * scrollPane.setPreferredSize(getSize()); 147 | * scrollPane.setSize(getSize()); 148 | */ 149 | 150 | add(scrollPane, BorderLayout.CENTER); 151 | } 152 | 153 | public Object[][] getMatrix() { 154 | return M; 155 | } 156 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/ParametersPanel.java: -------------------------------------------------------------------------------- 1 | package org.math.plot; 2 | 3 | import java.awt.*; 4 | import java.awt.event.*; 5 | 6 | import javax.swing.*; 7 | 8 | /** 9 | * BSD License 10 | * 11 | * @author Yann RICHET 12 | */ 13 | 14 | public class ParametersPanel extends JPanel implements ActionListener { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | private Dimension defaultSize; 19 | 20 | private String[] paramLabels; 21 | 22 | private String[] paramValues; 23 | 24 | private boolean[] isList; 25 | 26 | private int[] paramValuesIndex; 27 | 28 | private String[][] paramChoices; 29 | 30 | private JLabel[] labels; 31 | 32 | private JComboBox[] fields; 33 | 34 | private Runnable action; 35 | 36 | public ParametersPanel(String[] lab, String[] val) { 37 | this(lab, new int[lab.length], new String[][] { val }); 38 | } 39 | 40 | public ParametersPanel(String[] lab) { 41 | this(lab, new String[lab.length]); 42 | } 43 | 44 | public ParametersPanel(String[] lab, int[] selected, String[][] ch) { 45 | paramLabels = lab; 46 | 47 | isList = new boolean[paramLabels.length]; 48 | for (int i = 0; i < isList.length; i++) { 49 | isList[i] = true; 50 | } 51 | 52 | paramValuesIndex = selected; 53 | 54 | paramChoices = ch; 55 | 56 | paramValues = new String[paramLabels.length]; 57 | for (int i = 0; i < paramChoices.length; i++) { 58 | paramValues[i] = paramChoices[i][paramValuesIndex[i]]; 59 | } 60 | 61 | setComponents(); 62 | setAppearence(); 63 | draw(); 64 | } 65 | 66 | public ParametersPanel(String[] lab, String[][] ch) { 67 | this(lab, new int[lab.length], ch); 68 | } 69 | 70 | private void setComponents() { 71 | labels = new JLabel[paramLabels.length]; 72 | fields = new JComboBox[paramLabels.length]; 73 | for (int i = 0; i < paramLabels.length; i++) { 74 | labels[i] = new JLabel(paramLabels[i], JLabel.RIGHT); 75 | if (isList[i]) { 76 | fields[i] = new JComboBox(paramChoices[i]); 77 | } else { 78 | fields[i] = new JComboBox(); 79 | } 80 | fields[i].setEditable(!isList[i]); 81 | } 82 | defaultSize = new Dimension(400, paramLabels.length * 30); 83 | } 84 | 85 | private void setAppearence() { 86 | setPreferredSize(defaultSize); 87 | setSize(defaultSize); 88 | } 89 | 90 | private void update() { 91 | updateValues(); 92 | updateValuesIndex(); 93 | } 94 | 95 | private void updateValues() { 96 | for (int i = 0; i < paramLabels.length; i++) { 97 | paramValues[i] = (String) (fields[i].getSelectedItem()); 98 | } 99 | } 100 | 101 | private void updateValuesIndex() { 102 | for (int i = 0; i < paramLabels.length; i++) { 103 | if (isList[i]) { 104 | paramValuesIndex[i] = fields[i].getSelectedIndex(); 105 | } 106 | } 107 | } 108 | 109 | public void actionPerformed(ActionEvent e) { 110 | update(); 111 | new Thread(action, "PanelParameters " + this.toString() + " selection").start(); 112 | } 113 | 114 | public int getValueIndex(int i) { 115 | if (!isList[i]) { 116 | throw new IllegalArgumentException("This PanelParameter element is not set to give an Index."); 117 | } 118 | update(); 119 | return paramValuesIndex[i]; 120 | } 121 | 122 | public int[] getValuesIndex() { 123 | update(); 124 | return paramValuesIndex; 125 | } 126 | 127 | public String[] getValues() { 128 | update(); 129 | return paramValues; 130 | } 131 | 132 | public String getValue(int i) { 133 | update(); 134 | return paramValues[i]; 135 | } 136 | 137 | public void setAction(Runnable t) { 138 | action = t; 139 | } 140 | 141 | private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { 142 | gbc.gridx = gx; 143 | gbc.gridy = gy; 144 | gbc.gridwidth = gw; 145 | gbc.gridheight = gh; 146 | gbc.weightx = wx; 147 | gbc.weighty = wy; 148 | } 149 | 150 | private void draw() { 151 | JPanel panel = new JPanel(); 152 | 153 | GridBagLayout gbl = new GridBagLayout(); 154 | GridBagConstraints c = new GridBagConstraints(); 155 | panel.setLayout(gbl); 156 | 157 | for (int i = 0; i < paramLabels.length; i++) { 158 | fields[i].addActionListener(this); 159 | 160 | // Ajout du panel de la chaine 161 | buildConstraints(c, 0, i, 1, 1, 50, 20); 162 | c.anchor = GridBagConstraints.EAST; 163 | gbl.setConstraints(labels[i], c); 164 | panel.add(labels[i]); 165 | 166 | // Ajout du panel de la chaine 167 | buildConstraints(c, 1, i, 1, 1, 50, 20); 168 | c.fill = GridBagConstraints.HORIZONTAL; 169 | gbl.setConstraints(fields[i], c); 170 | panel.add(fields[i]); 171 | } 172 | 173 | JScrollPane scrollPane = new JScrollPane(panel); 174 | 175 | scrollPane.setPreferredSize(getSize()); 176 | scrollPane.setSize(getSize()); 177 | 178 | setLayout(new BorderLayout()); 179 | add(scrollPane, BorderLayout.CENTER); 180 | 181 | } 182 | 183 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/canvas/Plot2DCanvas.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.canvas; 2 | 3 | import java.awt.*; 4 | 5 | import org.math.plot.plotObjects.*; 6 | import org.math.plot.plots.*; 7 | import org.math.plot.render.*; 8 | 9 | import static org.math.plot.plotObjects.Base.*; 10 | import static org.math.plot.utils.Array.*; 11 | import static org.math.plot.utils.Histogram.*; 12 | 13 | /** 14 | * BSD License 15 | * 16 | * @author Yann RICHET 17 | */ 18 | public class Plot2DCanvas extends PlotCanvas { 19 | 20 | // public final static String PARALLELHISTOGRAM = "PARALLELHISTOGRAM"; 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | public Plot2DCanvas() { 25 | super(); 26 | ActionMode = ZOOM; 27 | } 28 | 29 | public Plot2DCanvas(Base b, BasePlot bp) { 30 | super(b, bp); 31 | ActionMode = ZOOM; 32 | } 33 | 34 | public Plot2DCanvas(double[] min, double[] max, String[] axesScales, String[] axesLabels) { 35 | super(min, max, axesScales, axesLabels); 36 | ActionMode = ZOOM; 37 | } 38 | 39 | public void initDrawer() { 40 | draw = new AWTDrawer2D(this); 41 | } 42 | 43 | public void initBasenGrid(double[] min, double[] max) { 44 | initBasenGrid(min, max, new String[] { LINEAR, LINEAR }, new String[] { "X", "Y" }); 45 | } 46 | 47 | public void initBasenGrid() { 48 | initBasenGrid(new double[] { 0, 0 }, new double[] { 1, 1 }); 49 | } 50 | 51 | private static double[][] convertY(double[] XY) { 52 | double[] x = increment(XY.length, 1, 1); 53 | return mergeColumns(x, XY); 54 | } 55 | 56 | private static double[][] convertXY(double[]... XY) { 57 | if (XY.length == 2 && XY[0].length != 2) 58 | return mergeColumns(XY[0], XY[1]); 59 | else 60 | return XY; 61 | } 62 | 63 | public int addScatterPlot(String name, Color c, double[] Y) { 64 | return addPlot(new ScatterPlot(name, c, convertY(Y))); 65 | } 66 | 67 | public int addScatterPlot(String name, Color c, double[][] XY) { 68 | return addPlot(new ScatterPlot(name, c, convertXY(XY))); 69 | } 70 | 71 | public int addScatterPlot(String name, Color c, double[] X, double[] Y) { 72 | return addPlot(new ScatterPlot(name, c, convertXY(X,Y))); 73 | } 74 | 75 | public int addLinePlot(String name, Color c, double[] Y) { 76 | return addPlot(new LinePlot(name, c, convertY(Y))); 77 | } 78 | 79 | public int addLinePlot(String name, Color c, double[][] XY) { 80 | return addPlot(new LinePlot(name, c, convertXY(XY))); 81 | } 82 | 83 | public int addLinePlot(String name, Color c, double[] X, double[] Y) { 84 | return addPlot(new LinePlot(name, c, convertXY(X,Y))); 85 | } 86 | 87 | public int addBarPlot(String name, Color c, double[] Y) { 88 | return addPlot(new BarPlot(name, c, convertY(Y))); 89 | } 90 | 91 | public int addBarPlot(String name, Color c, double[][] XY) { 92 | return addPlot(new BarPlot(name, c, convertXY(XY))); 93 | } 94 | 95 | public int addBarPlot(String name, Color c, double[] X, double[] Y) { 96 | return addPlot(new BarPlot(name, c, convertXY(X,Y))); 97 | } 98 | 99 | public int addStaircasePlot(String name, Color c, double[] Y) { 100 | return addPlot(new StaircasePlot(name, c, convertY(Y))); 101 | } 102 | 103 | public int addStaircasePlot(String name, Color c, double[][] XY) { 104 | return addPlot(new StaircasePlot(name, c, convertXY(XY))); 105 | } 106 | 107 | public int addStaircasePlot(String name, Color c, double[] X, double[] Y) { 108 | return addPlot(new StaircasePlot(name, c, convertXY(X,Y))); 109 | } 110 | 111 | 112 | public int addBoxPlot(String name, Color c, double[][] XY, double[][] dX) { 113 | return addPlot(new BoxPlot2D(XY, dX, c, name)); 114 | } 115 | 116 | public int addBoxPlot(String name, Color c, double[][] XYdX) { 117 | return addPlot(new BoxPlot2D(getColumnsRangeCopy(XYdX, 0, 1), getColumnsRangeCopy(XYdX, 2, 3), c, name)); 118 | } 119 | 120 | public int addHistogramPlot(String name, Color c, double[][] XY, double[] dX) { 121 | return addPlot(new HistogramPlot2D(name, c, XY, dX)); 122 | } 123 | 124 | public int addHistogramPlot(String name, Color c, double[][] XY, double dX) { 125 | return addPlot(new HistogramPlot2D(name, c, XY, dX)); 126 | } 127 | 128 | public int addHistogramPlot(String name, Color c, double[][] XYdX) { 129 | return addPlot(new HistogramPlot2D(name, c, getColumnsRangeCopy(XYdX, 0, 1), getColumnCopy(XYdX, 2))); 130 | } 131 | 132 | public int addHistogramPlot(String name, Color c, double[] X, int n) { 133 | double[][] XY = histogram_classes(X, n); 134 | return addPlot(new HistogramPlot2D(name, c, XY, XY[1][0] - XY[0][0])); 135 | } 136 | 137 | public int addHistogramPlot(String name, Color c, double[] X, double... bounds) { 138 | double[][] XY = histogram_classes(X, bounds); 139 | return addPlot(new HistogramPlot2D(name, c, XY, XY[1][0] - XY[0][0])); 140 | } 141 | 142 | public int addHistogramPlot(String name, Color c, double[] X, double min, double max, int n) { 143 | double[][] XY = histogram_classes(X, min, max, n); 144 | return addPlot(new HistogramPlot2D(name, c, XY, XY[1][0] - XY[0][0])); 145 | } 146 | 147 | public int addCloudPlot(String name, Color c, double[][] sampleXY, int nX, int nY) { 148 | double[][] XYh = histogram_classes_2D(sampleXY, nX, nY); 149 | return addPlot(new CloudPlot2D(name, c, XYh, XYh[1][0] - XYh[0][0], XYh[nX][1] - XYh[0][1])); 150 | } 151 | 152 | public static void main(String[] args) { 153 | /* 154 | * Plot2DPanel p2d = new Plot2DPanel(DoubleArray.random(10, 2), "plot 155 | * 1", PlotPanel.SCATTER); new FrameView(p2d); 156 | * p2d.addPlot(DoubleArray.random(10, 2), "plot 2", PlotPanel.SCATTER); 157 | * p2d.grid.getAxe(0).darkLabel.setCorner(0.5, -10); 158 | * p2d.grid.getAxe(1).darkLabel.setCorner(0, -0.5); 159 | */ 160 | } 161 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/canvas/Plot3DCanvas.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.canvas; 2 | 3 | import org.math.plot.utils.FastMath; 4 | import java.awt.*; 5 | import java.awt.event.*; 6 | 7 | import org.math.plot.plotObjects.*; 8 | import org.math.plot.plots.*; 9 | import org.math.plot.render.*; 10 | 11 | import static org.math.plot.plotObjects.Base.*; 12 | import static org.math.plot.utils.Array.*; 13 | import static org.math.plot.utils.Histogram.*; 14 | 15 | /** 16 | * BSD License 17 | * 18 | * @author Yann RICHET 19 | */ 20 | public class Plot3DCanvas extends PlotCanvas { 21 | 22 | private static final long serialVersionUID = 1L; 23 | public final static int ROTATION = 2; 24 | 25 | public Plot3DCanvas() { 26 | super(); 27 | ActionMode = ROTATION; 28 | } 29 | 30 | public Plot3DCanvas(Base b) { 31 | super(b, new BasePlot(b, "X", "Y", "Z")); 32 | ActionMode = ROTATION; 33 | } 34 | 35 | public Plot3DCanvas(Base b, BasePlot bp) { 36 | super(b, bp); 37 | ActionMode = ROTATION; 38 | } 39 | 40 | public Plot3DCanvas(double[] min, double[] max, String[] axesScales, String[] axesLabels) { 41 | super(min, max, axesScales, axesLabels); 42 | ActionMode = ROTATION; 43 | } 44 | 45 | public void initDrawer() { 46 | draw = new AWTDrawer3D(this); 47 | } 48 | 49 | public void initBasenGrid(double[] min, double[] max) { 50 | initBasenGrid(min, max, new String[]{LINEAR, LINEAR, LINEAR}, new String[]{"X", "Y", "Z"}); 51 | } 52 | 53 | public void initBasenGrid() { 54 | initBasenGrid(new double[]{0, 0, 0}, new double[]{1, 1, 1}); 55 | } 56 | 57 | private static double[][] convertXYZ(double[]... XYZ) { 58 | if (XYZ.length == 3 && XYZ[0].length != 3) { 59 | return mergeColumns(XYZ[0], XYZ[1], XYZ[2]); 60 | } else { 61 | return XYZ; 62 | } 63 | } 64 | 65 | public void setDefaultZoom(double zoom_factor) { 66 | ((Projection3D) ((AWTDrawer3D) draw).projection).factor = zoom_factor; 67 | } 68 | 69 | public int addScatterPlot(String name, Color c, double[][] XYZ) { 70 | return addPlot(new ScatterPlot(name, c, convertXYZ(XYZ))); 71 | } 72 | 73 | public int addScatterPlot(String name, Color c, double[] X, double[] Y, double[] Z) { 74 | return addPlot(new ScatterPlot(name, c, convertXYZ(X, Y, Z))); 75 | } 76 | 77 | public int addLinePlot(String name, Color c, double[][] XYZ) { 78 | return addPlot(new LinePlot(name, c, convertXYZ(XYZ))); 79 | } 80 | 81 | public int addLinePlot(String name, Color c, double[] X, double[] Y, double[] Z) { 82 | return addPlot(new LinePlot(name, c, convertXYZ(X, Y, Z))); 83 | } 84 | 85 | public int addBarPlot(String name, Color c, double[][] XYZ) { 86 | return addPlot(new BarPlot(name, c, convertXYZ(XYZ))); 87 | } 88 | 89 | public int addBarPlot(String name, Color c, double[] X, double[] Y, double[] Z) { 90 | return addPlot(new BarPlot(name, c, convertXYZ(X, Y, Z))); 91 | } 92 | 93 | public int addBoxPlot(String name, Color c, double[][] XY, double[][] dX) { 94 | return addPlot(new BoxPlot3D(XY, dX, c, name)); 95 | } 96 | 97 | public int addBoxPlot(String name, Color c, double[][] XYdX) { 98 | return addPlot(new BoxPlot3D(getColumnsRangeCopy(XYdX, 0, 2), getColumnsRangeCopy(XYdX, 3, 5), c, name)); 99 | } 100 | 101 | public int addHistogramPlot(String name, Color c, double[][] XY, double[][] dX) { 102 | return addPlot(new HistogramPlot3D(name, c, XY, dX)); 103 | } 104 | 105 | public int addHistogramPlot(String name, Color c, double[][] XYdX) { 106 | return addPlot(new HistogramPlot3D(name, c, getColumnsRangeCopy(XYdX, 0, 2), getColumnsRangeCopy(XYdX, 3, 4))); 107 | } 108 | 109 | public int addHistogramPlot(String name, Color c, double[][] XY, int nX, int nY) { 110 | double[][] XYZ = histogram_classes_2D(XY, nX, nY); 111 | return addPlot(new HistogramPlot3D(name, c, XYZ, XYZ[1][0] - XYZ[0][0], XYZ[nX][1] - XYZ[0][1])); 112 | } 113 | 114 | public int addHistogramPlot(String name, Color c, double[][] XY, double[] boundsX, double[] boundsY) { 115 | double[][] XYZ = histogram_classes_2D(XY, boundsX, boundsY); 116 | return addPlot(new HistogramPlot3D(name, c, XYZ, XYZ[1][0] - XYZ[0][0], XYZ[boundsX.length - 1][1] - XYZ[0][1])); 117 | } 118 | 119 | public int addHistogramPlot(String name, Color c, double[][] XY, double minX, double maxX, int nX, double minY, double maxY, int nY) { 120 | double[][] XYZ = histogram_classes_2D(XY, minX, maxX, nX, minY, maxY, nY); 121 | return addPlot(new HistogramPlot3D(name, c, XYZ, XYZ[1][0] - XYZ[0][0], XYZ[nX][1] - XYZ[0][1])); 122 | } 123 | 124 | public int addGridPlot(String name, Color c, double[] X, double[] Y, double[][] Z) { 125 | return addPlot(new GridPlot3D(name, c, X, Y, Z)); 126 | } 127 | 128 | public int addGridPlot(String name, Color c, double[][] XYZMatrix) { 129 | double[] X = new double[XYZMatrix[0].length - 1]; 130 | System.arraycopy(XYZMatrix[0], 1, X, 0, XYZMatrix[0].length - 1); 131 | double[] Y = new double[XYZMatrix.length - 1]; 132 | for (int i = 0; i < Y.length; i++) { 133 | Y[i] = XYZMatrix[i + 1][0]; 134 | } 135 | double[][] Z = getSubMatrixRangeCopy(XYZMatrix, 1, XYZMatrix.length - 1, 1, XYZMatrix[0].length - 1); 136 | 137 | return addGridPlot(name, c, X, Y, Z); 138 | } 139 | 140 | public int addCloudPlot(String name, Color c, double[][] sampleXYZ, int nX, int nY, int nZ) { 141 | double[][] XYZh = histogram_classes_3D(sampleXYZ, nX, nY, nZ); 142 | return addPlot(new CloudPlot3D(name, c, XYZh, XYZh[1][0] - XYZh[0][0], XYZh[nX][1] - XYZh[0][1], XYZh[nX][2] - XYZh[0][2])); 143 | } 144 | 145 | public void mouseDragged(MouseEvent e) { 146 | //System.out.println("PlotCanvas.mouseDragged"); 147 | if (ActionMode == ROTATION) { 148 | dragging = true; 149 | /* 150 | * System.out.println("PlotCanvas.mouseDragged"); System.out.println(" 151 | * mouseClick = [" + mouseClick[0] + " " + mouseClick[1] + "]"); 152 | * System.out.println(" mouseCurent = [" + mouseCurent[0] + " " + 153 | * mouseCurent[1] + "]"); 154 | */ 155 | mouseCurent[0] = e.getX(); 156 | mouseCurent[1] = e.getY(); 157 | e.consume(); 158 | 159 | int[] t = new int[]{mouseCurent[0] - mouseClick[0], mouseCurent[1] - mouseClick[1]}; 160 | ((AWTDrawer3D) draw).rotate(t, new int[]{getWidth(), getHeight()}); 161 | mouseClick[0] = mouseCurent[0]; 162 | mouseClick[1] = mouseCurent[1]; 163 | repaint(); 164 | } else { 165 | super.mouseDragged(e); 166 | } 167 | } 168 | 169 | public void rotate(double theta, double phi) { 170 | Projection3D proj3d = ((Projection3D) ((AWTDrawer) draw).projection); 171 | proj3d.rotate(proj3d.theta + theta, proj3d.phi + phi); 172 | } 173 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/components/DataFrame.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.components; 2 | 3 | import javax.swing.*; 4 | import org.math.plot.canvas.*; 5 | import org.math.plot.plots.*; 6 | 7 | /** 8 | * BSD License 9 | * 10 | * @author Yann RICHET 11 | */ 12 | public class DataFrame extends JFrame { 13 | 14 | private static final long serialVersionUID = 1L; 15 | private PlotCanvas plotCanvas; 16 | private JTabbedPane panels; 17 | 18 | public DataFrame(PlotCanvas p) { 19 | super("Data"); 20 | plotCanvas = p; 21 | JPanel panel = new JPanel(); 22 | panels = new JTabbedPane(); 23 | 24 | panel.add(panels); 25 | setContentPane(panel); 26 | //setVisible(true); 27 | } 28 | 29 | @Override 30 | public void setVisible(boolean b) { 31 | if (b) { 32 | setPanel(); 33 | } 34 | super.setVisible(b); 35 | } 36 | 37 | private void setPanel() { 38 | panels.removeAll(); 39 | for (Plot plot : plotCanvas.getPlots()) { 40 | panels.add(plot.getDataPanel(plotCanvas), plot.getName()); 41 | } 42 | pack(); 43 | } 44 | 45 | public void selectIndex(int i) { 46 | setVisible(true); 47 | if (panels.getTabCount() > i) { 48 | panels.setSelectedIndex(i); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/components/DataToolBar.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.components; 2 | 3 | import java.awt.event.*; 4 | import java.security.*; 5 | 6 | import javax.swing.*; 7 | 8 | import org.math.plot.*; 9 | 10 | /** 11 | * BSD License 12 | * 13 | * @author Yann RICHET 14 | */ 15 | 16 | public class DataToolBar extends JToolBar { 17 | 18 | /** 19 | * Comment for serialVersionUID 20 | */ 21 | private static final long serialVersionUID = 1L; 22 | 23 | protected JButton buttonPasteToClipboard; 24 | 25 | protected JButton buttonSaveFile; 26 | 27 | private boolean denySaveSecurity; 28 | 29 | private JFileChooser fileChooser; 30 | 31 | private DataPanel dataPanel; 32 | 33 | public DataToolBar(DataPanel dp) { 34 | 35 | dataPanel = dp; 36 | 37 | try { 38 | fileChooser = new JFileChooser(); 39 | } catch (AccessControlException ace) { 40 | denySaveSecurity = true; 41 | } 42 | 43 | buttonPasteToClipboard = new JButton(new ImageIcon(org.math.plot.PlotPanel.class.getResource("icons/toclipboard.png"))); 44 | buttonPasteToClipboard.setToolTipText("Copy data to clipboard"); 45 | 46 | buttonSaveFile = new JButton(new ImageIcon(org.math.plot.PlotPanel.class.getResource("icons/tofile.png"))); 47 | buttonSaveFile.setToolTipText("Save data into ASCII file"); 48 | 49 | buttonPasteToClipboard.addActionListener(new ActionListener() { 50 | public void actionPerformed(ActionEvent e) { 51 | dataPanel.toClipBoard(); 52 | } 53 | }); 54 | buttonSaveFile.addActionListener(new ActionListener() { 55 | public void actionPerformed(ActionEvent e) { 56 | chooseFile(); 57 | } 58 | }); 59 | 60 | add(buttonPasteToClipboard, null); 61 | add(buttonSaveFile, null); 62 | 63 | if (!denySaveSecurity) { 64 | fileChooser.addActionListener(new java.awt.event.ActionListener() { 65 | public void actionPerformed(ActionEvent e) { 66 | saveFile(); 67 | } 68 | }); 69 | } else { 70 | buttonSaveFile.setEnabled(false); 71 | } 72 | } 73 | 74 | void saveFile() { 75 | java.io.File file = fileChooser.getSelectedFile(); 76 | dataPanel.toASCIIFile(file); 77 | } 78 | 79 | void chooseFile() { 80 | fileChooser.showSaveDialog(this); 81 | } 82 | 83 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/components/DatasFrame.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.components; 2 | 3 | import java.awt.*; 4 | import java.awt.event.*; 5 | 6 | import javax.swing.*; 7 | import javax.swing.event.*; 8 | 9 | import org.math.plot.*; 10 | import org.math.plot.canvas.*; 11 | import org.math.plot.plots.*; 12 | 13 | /** 14 | * BSD License 15 | * 16 | * @author Yann RICHET 17 | */ 18 | 19 | public class DatasFrame extends JFrame { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | private PlotCanvas plotCanvas; 24 | 25 | private LegendPanel legend; 26 | 27 | public JTabbedPane panels; 28 | 29 | public DatasFrame(PlotCanvas p, LegendPanel l) { 30 | super("Data"); 31 | plotCanvas = p; 32 | legend = l; 33 | JPanel panel = new JPanel(); 34 | panels = new JTabbedPane(); 35 | 36 | for (Plot plot: plotCanvas.getPlots()) 37 | panels.add(new DataPanel(/*this, */plot), plot.getName()); 38 | 39 | 40 | panel.add(panels); 41 | setContentPane(panel); 42 | pack(); 43 | setVisible(true); 44 | } 45 | 46 | public class DataPanel extends JPanel { 47 | 48 | private static final long serialVersionUID = 1L; 49 | 50 | MatrixTablePanel XY; 51 | 52 | JCheckBox visible; 53 | 54 | JButton color; 55 | 56 | JPanel plottoolspanel; 57 | 58 | Plot plot; 59 | 60 | DatasFrame dframe; 61 | 62 | public DataPanel(/*DatasFrame _dframe,*/Plot _plot) { 63 | plot = _plot; 64 | //dframe = _dframe; 65 | visible = new JCheckBox("visible"); 66 | visible.setSelected(plot.getVisible()); 67 | color = new JButton(); 68 | color.setBackground(plot.getColor()); 69 | XY = new MatrixTablePanel( plotCanvas.reverseMapedData( plot.getData())); 70 | 71 | visible.addChangeListener(new ChangeListener() { 72 | public void stateChanged(ChangeEvent e) { 73 | if (visible.isSelected()) 74 | plot.setVisible(true); 75 | else 76 | plot.setVisible(false); 77 | /*dframe.*/plotCanvas.repaint(); 78 | } 79 | }); 80 | color.addActionListener(new ActionListener() { 81 | public void actionPerformed(ActionEvent e) { 82 | Color c = JColorChooser.showDialog(plotCanvas, "Choose plot color", plot.getColor()); 83 | color.setBackground(c); 84 | plot.setColor(c); 85 | legend.updateLegends(); 86 | /*dframe.*/plotCanvas.linkedLegendPanel.repaint(); 87 | /*dframe.*/plotCanvas.repaint(); 88 | } 89 | }); 90 | 91 | this.setLayout(new BorderLayout()); 92 | plottoolspanel = new JPanel(); 93 | plottoolspanel.add(visible); 94 | plottoolspanel.add(color); 95 | this.add(plottoolspanel, BorderLayout.NORTH); 96 | this.add(XY, BorderLayout.CENTER); 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/BaseDependant.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plotObjects; 2 | 3 | /** 4 | * BSD License 5 | * 6 | * @author Yann RICHET 7 | */ 8 | 9 | public interface BaseDependant { 10 | public void resetBase(); 11 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/BaseLabel.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plotObjects; 2 | 3 | import java.awt.*; 4 | 5 | import org.math.plot.*; 6 | import org.math.plot.canvas.*; 7 | import org.math.plot.render.*; 8 | 9 | /** 10 | * BSD License 11 | * 12 | * @author Yann RICHET 13 | */ 14 | 15 | public class BaseLabel extends Label /* implements BaseDependant */{ 16 | 17 | public BaseLabel(String l, Color c, double... rC) { 18 | super(l, c, rC); 19 | } 20 | 21 | /* 22 | * public void resetBase() { System.out.println("BaseLabel.resetBase"); } 23 | */ 24 | 25 | public static void main(String[] args) { 26 | Plot3DCanvas p3d = new Plot3DCanvas(new double[] { 0, 0, 0 }, new double[] { 10, 10, 10 }, new String[] { "lin", "lin", "lin" }, new String[] { "x", 27 | "y", "z" }); 28 | new FrameView(p3d); 29 | // p3d.addPlot(DoubleArray.random(10, 3), "plot", "SCATTER"); 30 | p3d.addPlotable(new BaseLabel("label", Color.RED, new double[] { -0.1, 0.5, 0.5 })); 31 | } 32 | 33 | public void plot(AbstractDrawer draw) { 34 | draw.setColor(color); 35 | draw.setFont(font); 36 | draw.setTextAngle(angle); 37 | draw.setTextOffset(cornerE, cornerN); 38 | draw.drawTextBase(label, coord); 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/BaseLine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on 1 juin 2005 by richet 3 | */ 4 | package org.math.plot.plotObjects; 5 | 6 | import java.awt.*; 7 | 8 | import org.math.plot.render.*; 9 | 10 | public class BaseLine extends Line { 11 | 12 | public BaseLine(Color col, double[] c1, double[] c2) { 13 | super(col, c1, c2); 14 | } 15 | 16 | public void plot(AbstractDrawer draw) { 17 | if (!visible) 18 | return; 19 | 20 | draw.setColor(color); 21 | draw.drawLineBase(extrem[0], extrem[1]); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/BasePlot.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plotObjects; 2 | 3 | /** 4 | * BSD License 5 | * 6 | * @author Yann RICHET 7 | */ 8 | 9 | import java.awt.*; 10 | 11 | import org.math.plot.render.*; 12 | 13 | public class BasePlot implements /*Plotable,*/BaseDependant { 14 | 15 | public static Color DEFAULT_COLOR = Color.DARK_GRAY; 16 | 17 | protected Base base; 18 | 19 | protected Axis[] axis; 20 | 21 | protected boolean visible = true; 22 | 23 | protected Color color; 24 | 25 | public BasePlot(Base b, String... as) { 26 | this(b, DEFAULT_COLOR, as); 27 | } 28 | 29 | public BasePlot(Base b, Color c, Axis... a) { 30 | base = b; 31 | axis = a; 32 | color = c; 33 | } 34 | 35 | public BasePlot(Base b, Color c, String... as) { 36 | base = b; 37 | if (as.length != base.dimension) { 38 | throw new IllegalArgumentException("String array of axes names must have " + base.dimension + " elements."); 39 | } 40 | color = c; 41 | axis = new Axis[base.dimension]; 42 | for (int i = 0; i < base.dimension; i++) { 43 | axis[i] = new Axis(base, as[i], color, i); 44 | } 45 | // resetBase(); 46 | } 47 | 48 | public void setVisible(boolean v) { 49 | visible = v; 50 | } 51 | 52 | public void setVisible(int i, boolean v) { 53 | axis[i].setVisible(v); 54 | } 55 | 56 | public void setGridVisible(int i, boolean v) { 57 | axis[i].setGridVisible(v); 58 | } 59 | 60 | public boolean getVisible() { 61 | return visible; 62 | } 63 | 64 | public void setColor(Color c) { 65 | color = c; 66 | for (int i = 0; i < axis.length; i++) { 67 | axis[i].setColor(c); 68 | } 69 | } 70 | 71 | public Color getColor() { 72 | return color; 73 | } 74 | 75 | public void setLegend(String[] as) { 76 | if (as.length != base.dimension) { 77 | throw new IllegalArgumentException("String array of axes names must have " + base.dimension + " elements."); 78 | } 79 | for (int i = 0; i < axis.length; i++) { 80 | axis[i].setLegend(as[i]); 81 | } 82 | // resetBase(); 83 | } 84 | 85 | public void setLegend(int i, String as) { 86 | axis[i].setLegend(as); 87 | // resetBase(); 88 | } 89 | 90 | public String[] getLegend() { 91 | String[] array = new String[axis.length]; 92 | for (int i = 0; i < array.length; i++) { 93 | array[i] = axis[i].getLegend(); 94 | } 95 | return array; 96 | } 97 | 98 | public String getLegend(int i) { 99 | return axis[i].getLegend(); 100 | } 101 | 102 | public void setBase(Base b) { 103 | base = b; 104 | for (int i = 0; i < axis.length; i++) { 105 | axis[i].base = base; 106 | } 107 | resetBase(); 108 | } 109 | 110 | public void plot(AbstractDrawer draw) { 111 | if (!visible) 112 | return; 113 | 114 | for (int i = 0; i < axis.length; i++) 115 | axis[i].plot(draw); 116 | } 117 | 118 | public Axis getAxis(int i) { 119 | return axis[i]; 120 | } 121 | 122 | public Axis[] getAxis() { 123 | return axis; 124 | } 125 | 126 | public void resetBase() { 127 | // System.out.println("BasePlot.resetBase"); 128 | for (int i = 0; i < axis.length; i++) { 129 | axis[i].resetBase(); 130 | //base.setAxesScales(i, Base.LINEAR); 131 | } 132 | } 133 | 134 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/Editable.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plotObjects; 2 | 3 | import org.math.plot.render.*; 4 | 5 | /** 6 | * BSD License 7 | * 8 | * @author Yann RICHET 9 | */ 10 | public interface Editable { 11 | public double[] isSelected(int[] screenCoord, AbstractDrawer draw); 12 | 13 | public void edit(Object editParent); 14 | 15 | public void editnote(AbstractDrawer draw); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/Label.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plotObjects; 2 | 3 | import java.awt.*; 4 | 5 | import org.math.plot.render.*; 6 | 7 | /** 8 | * BSD License 9 | * 10 | * @author Yann RICHET 11 | */ 12 | public class Label implements Plotable { 13 | 14 | protected double[] coord; 15 | 16 | protected double[] base_offset; 17 | 18 | protected String label; 19 | 20 | protected Color color; 21 | 22 | protected double cornerN = 0.5; 23 | 24 | protected double cornerE = 0.5; 25 | 26 | boolean visible = true; 27 | 28 | public double angle = 0; 29 | 30 | public Font font = AbstractDrawer.DEFAULT_FONT; 31 | 32 | // private static DecimalFormat dec = new DecimalFormat("##0.###E0"); 33 | 34 | public Label(String l, Color col, double... c) { 35 | label = l; 36 | coord = c; 37 | color = col; 38 | } 39 | 40 | public Label(String l, double... c) { 41 | this(l, AbstractDrawer.DEFAULT_COLOR, c); 42 | } 43 | 44 | /** 45 | * show coord itself 46 | */ 47 | public Label(double... c) { 48 | this(coordToString(c), AbstractDrawer.DEFAULT_COLOR, c); 49 | } 50 | 51 | public void setText(String _t) { 52 | label = _t; 53 | } 54 | 55 | public String getText() { 56 | return label; 57 | } 58 | 59 | public void setCoord(double... _c) { 60 | coord = _c; 61 | } 62 | 63 | public void setColor(Color c) { 64 | color = c; 65 | } 66 | 67 | public Color getColor() { 68 | return color; 69 | } 70 | 71 | /** 72 | * reference point center: 0.5, 0.5 lowerleft: 0,0 upperleft 1, 0 ... 73 | */ 74 | public void setCorner(double north_south, double east_west) { 75 | cornerN = north_south; 76 | cornerE = east_west; 77 | } 78 | 79 | public void setVisible(boolean v) { 80 | visible = v; 81 | } 82 | 83 | public boolean getVisible() { 84 | return visible; 85 | } 86 | 87 | /** 88 | * shift by given screen coordinates offset 89 | */ 90 | /* 91 | * public void setOffset(double[] offset) { double[] newCoord = 92 | * coord.getPlotCoordCopy(); for (int i = 0; i < newCoord.length; i++) { 93 | * newCoord[i] += offset[i]; } coord.setPlotCoord(newCoord); } 94 | */ 95 | 96 | /** 97 | * see Text for formatted text output 98 | */ 99 | public void plot(AbstractDrawer draw) { 100 | if (!visible) return; 101 | 102 | draw.setColor(color); 103 | draw.setFont(font); 104 | draw.setBaseOffset(base_offset); 105 | draw.setTextOffset(cornerE, cornerN); 106 | draw.setTextAngle(angle); 107 | draw.drawText(label, coord); 108 | draw.setBaseOffset(null); 109 | } 110 | 111 | public void rotate(double _angle) { 112 | angle = _angle; 113 | } 114 | 115 | public void setFont(Font _font) { 116 | font = _font; 117 | } 118 | 119 | public static double approx(double val, int decimal) { 120 | // double timesEn = val*Math.pow(10,decimal); 121 | // if (Math.rint(timesEn) == timesEn) { 122 | // return val; 123 | // } else { 124 | // to limit precision loss, you need to separate cases where decimal<0 125 | // and >0 126 | // if you don't you'll have this : approx(10000.0,-4) => 10000.00000001 127 | if (decimal < 0) { 128 | return Math.rint(val / Math.pow(10, -decimal)) * Math.pow(10, -decimal); 129 | } else { 130 | return Math.rint(val * Math.pow(10, decimal)) / Math.pow(10, decimal); 131 | } 132 | // } 133 | } 134 | 135 | public static String coordToString(double... c) { 136 | StringBuffer sb = new StringBuffer("("); 137 | for (int i = 0; i < c.length; i++) 138 | sb.append(approx(c[i], 2)).append(","); 139 | // sb.append(dec.format(c.getPlotCoordCopy()[i])).append(","); 140 | 141 | sb.setLength(sb.length() - 1); 142 | if (sb.length() > 0) 143 | sb.append(")"); 144 | 145 | return sb.toString(); 146 | } 147 | 148 | public Font getFont() { 149 | return font; 150 | } 151 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/Line.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plotObjects; 2 | 3 | import java.awt.*; 4 | 5 | import org.math.plot.render.*; 6 | 7 | /** 8 | * BSD License 9 | * 10 | * @author Yann RICHET 11 | */ 12 | public class Line implements Plotable { 13 | 14 | protected double[][] extrem = new double[2][]; 15 | 16 | protected Color color; 17 | 18 | protected Color gradientColor; 19 | 20 | boolean visible = true; 21 | 22 | public Line(Color col, double[] c1, double[] c2) { 23 | extrem[0] = c1; 24 | extrem[1] = c2; 25 | color = col; 26 | } 27 | 28 | public void setColor(Color c) { 29 | color = c; 30 | } 31 | 32 | public Color getColor() { 33 | return color; 34 | } 35 | 36 | public void setVisible(boolean v) { 37 | visible = v; 38 | } 39 | 40 | public boolean getVisible() { 41 | return visible; 42 | } 43 | 44 | public void plot(AbstractDrawer draw) { 45 | if (!visible) 46 | return; 47 | 48 | draw.setColor(color); 49 | if (gradientColor!= null) 50 | draw.setGradient(extrem[0], color, extrem[1], gradientColor); 51 | draw.drawLine(extrem[0], extrem[1]); 52 | if (gradientColor!= null) 53 | draw.resetGradient(); 54 | } 55 | 56 | public Color getGradientColor() { 57 | return gradientColor; 58 | } 59 | 60 | public void setGradientColor(Color c) { 61 | this.gradientColor = c; 62 | } 63 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/Noteable.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plotObjects; 2 | 3 | import org.math.plot.render.*; 4 | 5 | /** 6 | * BSD License 7 | * 8 | * @author Yann RICHET 9 | */ 10 | public interface Noteable { 11 | public double[] isSelected(int[] screenCoord, AbstractDrawer draw); 12 | 13 | public void note(AbstractDrawer draw); 14 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/PaintImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on 5 sept. 2005 by richet 3 | */ 4 | package org.math.plot.plotObjects; 5 | 6 | import java.awt.*; 7 | 8 | 9 | import org.math.plot.render.*; 10 | 11 | public class PaintImage implements Plotable { 12 | 13 | public interface Paintable { 14 | 15 | public void paint(Graphics g); 16 | } 17 | protected Paintable source; 18 | protected Image img; 19 | protected double[] xyzSW, xyzSE, xyzNW; 20 | protected boolean visible = true; 21 | protected float alpha; 22 | 23 | public PaintImage(Paintable _source, float _alpha, double[] _xyzSW, double[] _xyzSE, double[] _xyzNW) { 24 | source = _source; 25 | 26 | xyzSW = _xyzSW; 27 | xyzSE = _xyzSE; 28 | xyzNW = _xyzNW; 29 | alpha = _alpha; 30 | } 31 | 32 | public void plot(AbstractDrawer draw) { 33 | if (!visible) { 34 | return; 35 | } 36 | 37 | if (img == null) { 38 | img = draw.canvas.createImage(draw.canvas.getWidth(), draw.canvas.getHeight()); 39 | source.paint(img.getGraphics()); 40 | } 41 | 42 | draw.drawImage(img, alpha, xyzSW, xyzSE, xyzNW); 43 | } 44 | 45 | public void setVisible(boolean v) { 46 | visible = v; 47 | } 48 | 49 | public boolean getVisible() { 50 | return visible; 51 | } 52 | 53 | public void setColor(Color c) { 54 | throw new IllegalArgumentException("method not available for this Object: PlotImage"); 55 | } 56 | 57 | public Color getColor() { 58 | return null; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/Plotable.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plotObjects; 2 | 3 | import java.awt.*; 4 | 5 | import org.math.plot.render.*; 6 | 7 | /** 8 | * BSD License 9 | * 10 | * @author Yann RICHET 11 | */ 12 | public interface Plotable { 13 | public void plot(AbstractDrawer draw); 14 | 15 | public void setVisible(boolean v); 16 | 17 | public boolean getVisible(); 18 | 19 | public void setColor(Color c); 20 | 21 | public Color getColor(); 22 | 23 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plotObjects/RasterImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on 5 sept. 2005 by richet 3 | */ 4 | package org.math.plot.plotObjects; 5 | 6 | import java.awt.*; 7 | import java.io.*; 8 | 9 | import javax.swing.*; 10 | 11 | import org.math.plot.*; 12 | import org.math.plot.render.*; 13 | 14 | public class RasterImage implements Plotable{ 15 | 16 | File source; 17 | Image img; 18 | 19 | double[] xyzSW, xyzSE,xyzNW; 20 | 21 | boolean visible = true; 22 | float alpha; 23 | 24 | public RasterImage(File _source, float _alpha,double[] _xyzSW, double[] _xyzSE,double[] _xyzNW) { 25 | source = _source; 26 | img = Toolkit.getDefaultToolkit().getImage(source.getPath()); 27 | xyzSW = _xyzSW; 28 | xyzSE = _xyzSE; 29 | xyzNW=_xyzNW; 30 | alpha = _alpha; 31 | } 32 | 33 | public void plot(AbstractDrawer draw) { 34 | if (!visible) return; 35 | 36 | draw.drawImage(img,alpha, xyzSW, xyzSE,xyzNW); 37 | } 38 | 39 | public void setVisible(boolean v) { 40 | visible = v; 41 | } 42 | 43 | public boolean getVisible() { 44 | return visible; 45 | } 46 | 47 | public void setColor(Color c) { 48 | throw new IllegalArgumentException("method not available for this Object: PlotImage"); 49 | } 50 | 51 | public Color getColor() { 52 | return null; 53 | } 54 | 55 | public static void main(String[] args) { 56 | Plot2DPanel p2 = new Plot2DPanel(); 57 | for (int i = 0; i < 1; i++) { 58 | double[][] XYZ = new double[10][2]; 59 | for (int j = 0; j < XYZ.length; j++) { 60 | XYZ[j][0] =/*1 + */Math.random(); 61 | XYZ[j][1] = /*100 * */Math.random(); 62 | } 63 | p2.addScatterPlot("toto" + i, XYZ); 64 | } 65 | 66 | p2.addPlotable(new RasterImage(new File("test.gif"), 0.8f,new double[] {0.2,0.5},new double[] {1.2,0.8},new double[] {0.2,1.1})); 67 | 68 | p2.setLegendOrientation(PlotPanel.SOUTH); 69 | new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 70 | 71 | 72 | 73 | Plot3DPanel p = new Plot3DPanel(); 74 | for (int i = 0; i < 1; i++) { 75 | double[][] XYZ = new double[10][3]; 76 | for (int j = 0; j < XYZ.length; j++) { 77 | XYZ[j][0] = /*1 +*/ Math.random(); 78 | XYZ[j][1] = /*100 **/ Math.random(); 79 | XYZ[j][2] = /*0.0001 **/ Math.random(); 80 | } 81 | p.addScatterPlot("toto" + i, XYZ); 82 | } 83 | 84 | p.addPlotable(new RasterImage(new File("test.gif"), 0.5f, new double[] {0.0,0.0,0.0},new double[] {1,0,0.0},new double[] {0.0,0,1})); 85 | p.addPlotable(new RasterImage(new File("test.gif"), 0.5f, new double[] {0.0,0.0,0.0},new double[] {0,1,0.0},new double[] {0,0.0,1})); 86 | p.addPlotable(new RasterImage(new File("test.gif"),0.5f, new double[] {0.0,0.0,0.0},new double[] {1,0,0},new double[] {0,1,0})); 87 | // TODO this following case is not totally supported... 88 | //p.addPlotable(new PlotImage(new File("test.jpg"),0.5f, new double[] {1,0,0},new double[] {1,1,0},new double[] {0,0,1})); 89 | 90 | 91 | p.setLegendOrientation(PlotPanel.SOUTH); 92 | p.setPreferredSize(new Dimension(600,600)); 93 | new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/BarPlot.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.*; 4 | 5 | import javax.swing.*; 6 | 7 | import org.math.plot.*; 8 | import org.math.plot.render.*; 9 | import org.math.plot.utils.*; 10 | 11 | public class BarPlot extends ScatterPlot { 12 | 13 | public boolean draw_dot = true; 14 | 15 | public BarPlot(String n, Color c, boolean[][] _pattern, double[][] _XY) { 16 | super(n, c, _pattern, _XY); 17 | } 18 | 19 | public BarPlot(String n, Color c, int _type, int _radius, double[][] _XY) { 20 | super(n, c, _type, _radius, _XY); 21 | } 22 | 23 | public BarPlot(String n, Color c, double[][] _XY) { 24 | super(n, c, _XY); 25 | } 26 | 27 | public void plot(AbstractDrawer draw, Color c) { 28 | if (!visible) 29 | return; 30 | 31 | if (draw_dot) 32 | super.plot(draw, c); 33 | 34 | draw.setColor(c); 35 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 36 | for (int i = 0; i < XY.length; i++) { 37 | double[] axeprojection = Array.copy(XY[i]); 38 | axeprojection[axeprojection.length - 1] = draw.canvas.base.baseCoords[0][axeprojection.length - 1]; 39 | draw.drawLine(XY[i], axeprojection); 40 | } 41 | } 42 | 43 | public static void main(String[] args) { 44 | Plot2DPanel p2 = new Plot2DPanel(); 45 | for (int i = 0; i < 3; i++) { 46 | double[][] XYZ = new double[10][2]; 47 | for (int j = 0; j < XYZ.length; j++) { 48 | XYZ[j][0] = /*1 + */Math.random(); 49 | XYZ[j][1] = /*100 * */Math.random(); 50 | } 51 | p2.addBarPlot("toto" + i, XYZ); 52 | } 53 | 54 | p2.setLegendOrientation(PlotPanel.SOUTH); 55 | new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 56 | 57 | Plot3DPanel p = new Plot3DPanel(); 58 | for (int i = 0; i < 3; i++) { 59 | double[][] XYZ = new double[10][3]; 60 | for (int j = 0; j < XYZ.length; j++) { 61 | XYZ[j][0] = /*1 +*/Math.random(); 62 | XYZ[j][1] = /*100 **/Math.random(); 63 | XYZ[j][2] = /*0.0001 **/Math.random(); 64 | } 65 | p.addBarPlot("toto" + i, XYZ); 66 | } 67 | 68 | p.setLegendOrientation(PlotPanel.SOUTH); 69 | new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 70 | } 71 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/BoxPlot2D.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.*; 4 | 5 | import org.math.plot.render.*; 6 | import org.math.plot.utils.Array; 7 | 8 | public class BoxPlot2D extends Plot { 9 | 10 | double[] Xmin; 11 | double[] Xmax; 12 | double[] Ymin; 13 | double[] Ymax; 14 | double[][] widths; 15 | double[][] XY; 16 | 17 | public BoxPlot2D(double[][] _XY, double[][] w, Color c, String n) { 18 | super(n, c); 19 | XY = _XY; 20 | widths = w; 21 | 22 | // double[] datasMin = Array.min(XY); 23 | // double[] datasMax = Array.max(XY); 24 | // double[] widthsMax = Array.max(widths); 25 | // double[] min = { datasMin[0] - widthsMax[0] / 2, datasMin[1] - 26 | // widthsMax[1] / 2 }; 27 | // double[] max = { datasMax[0] + widthsMax[0] / 2, datasMax[1] + 28 | // widthsMax[1] / 2 }; 29 | // base.includeInBounds(min); 30 | // base.includeInBounds(max); 31 | 32 | Xmin = new double[XY.length]; 33 | Xmax = new double[XY.length]; 34 | Ymin = new double[XY.length]; 35 | Ymax = new double[XY.length]; 36 | for (int i = 0; i < XY.length; i++) { 37 | Xmin[i] = XY[i][0] - widths[i][0] / 2; 38 | Xmax[i] = XY[i][0] + widths[i][0] / 2; 39 | Ymin[i] = XY[i][1] - widths[i][1] / 2; 40 | Ymax[i] = XY[i][1] + widths[i][1] / 2; 41 | } 42 | 43 | } 44 | 45 | public void plot(AbstractDrawer draw, Color c) { 46 | if (!visible) { 47 | return; 48 | } 49 | 50 | draw.setColor(c); 51 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 52 | for (int i = 0; i < XY.length; i++) { 53 | draw.drawLine(new double[]{Xmin[i], Ymin[i]}, new double[]{Xmax[i], Ymin[i]}); 54 | draw.drawLine(new double[]{Xmax[i], Ymin[i]}, new double[]{Xmax[i], Ymax[i]}); 55 | draw.drawLine(new double[]{Xmax[i], Ymax[i]}, new double[]{Xmin[i], Ymax[i]}); 56 | draw.drawLine(new double[]{Xmin[i], Ymax[i]}, new double[]{Xmin[i], Ymin[i]}); 57 | draw.setDotType(AbstractDrawer.ROUND_DOT); 58 | draw.setDotRadius(AbstractDrawer.DEFAULT_DOT_RADIUS); 59 | draw.drawDot(XY[i]); 60 | } 61 | } 62 | 63 | @Override 64 | public void setData(double[][] d) { 65 | datapanel = null; 66 | XY = d; 67 | } 68 | 69 | @Override 70 | public double[][] getData() { 71 | return XY; 72 | } 73 | 74 | @Override 75 | public double[][] getBounds() { 76 | return new double[][]{{Array.min(Xmin), Array.min(Ymin)}, {Array.max(Xmax), Array.max(Ymax)}}; 77 | } 78 | 79 | public void setDataWidth(double[][] w) { 80 | widths = w; 81 | } 82 | 83 | public double[][] getDataWidth() { 84 | return widths; 85 | } 86 | 87 | public void setData(double[][] d, double[][] w) { 88 | setData(d); 89 | widths = w; 90 | } 91 | 92 | public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) { 93 | for (int i = 0; i < XY.length; i++) { 94 | int[] screenCoord = draw.project(XY[i]); 95 | 96 | if ((screenCoord[0] + note_precision > screenCoordTest[0]) && (screenCoord[0] - note_precision < screenCoordTest[0]) 97 | && (screenCoord[1] + note_precision > screenCoordTest[1]) && (screenCoord[1] - note_precision < screenCoordTest[1])) { 98 | return XY[i]; 99 | } 100 | } 101 | return null; 102 | } 103 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/BoxPlot3D.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.*; 4 | 5 | import javax.swing.JFrame; 6 | import org.math.plot.FrameView; 7 | import org.math.plot.Plot3DPanel; 8 | import org.math.plot.PlotPanel; 9 | import org.math.plot.render.*; 10 | import org.math.plot.utils.Array; 11 | 12 | public class BoxPlot3D extends Plot { 13 | 14 | double[] Xmin; 15 | double[] Xmax; 16 | double[] Ymin; 17 | double[] Ymax; 18 | double[] Zmin; 19 | double[] Zmax; 20 | double[][] widths; 21 | double[][] XY; 22 | 23 | public BoxPlot3D(double[][] _XY, double[][] w, Color c, String n) { 24 | super(n, c); 25 | XY = _XY; 26 | widths = w; 27 | 28 | // double[] datasMin = Array.min(XY); 29 | // double[] datasMax = Array.max(XY); 30 | // double[] widthsMax = Array.max(widths); 31 | // double[] min = { datasMin[0] - widthsMax[0] / 2, datasMin[1] - 32 | // widthsMax[1] / 2, datasMin[2] - widthsMax[2] / 2 }; 33 | // double[] max = { datasMax[0] + widthsMax[0] / 2, datasMax[1] + 34 | // widthsMax[1] / 2, datasMax[2] + widthsMax[2] / 2 }; 35 | // base.includeInBounds(min); 36 | // base.includeInBounds(max); 37 | 38 | Xmin = new double[XY.length]; 39 | Xmax = new double[XY.length]; 40 | Ymin = new double[XY.length]; 41 | Ymax = new double[XY.length]; 42 | Zmin = new double[XY.length]; 43 | Zmax = new double[XY.length]; 44 | for (int i = 0; i < XY.length; i++) { 45 | Xmin[i] = XY[i][0] - widths[i][0] / 2; 46 | Xmax[i] = XY[i][0] + widths[i][0] / 2; 47 | Ymin[i] = XY[i][1] - widths[i][1] / 2; 48 | Ymax[i] = XY[i][1] + widths[i][1] / 2; 49 | Zmin[i] = XY[i][2] - widths[i][2] / 2; 50 | Zmax[i] = XY[i][2] + widths[i][2] / 2; 51 | } 52 | } 53 | 54 | public void plot(AbstractDrawer draw, Color c) { 55 | if (!visible) { 56 | return; 57 | } 58 | 59 | draw.setColor(c); 60 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 61 | for (int i = 0; i < XY.length; i++) { 62 | draw.drawLine(new double[]{Xmin[i], Ymin[i], Zmin[i]}, new double[]{Xmax[i], Ymin[i], Zmin[i]}); 63 | draw.drawLine(new double[]{Xmax[i], Ymin[i], Zmin[i]}, new double[]{Xmax[i], Ymax[i], Zmin[i]}); 64 | draw.drawLine(new double[]{Xmax[i], Ymax[i], Zmin[i]}, new double[]{Xmin[i], Ymax[i], Zmin[i]}); 65 | draw.drawLine(new double[]{Xmin[i], Ymax[i], Zmin[i]}, new double[]{Xmin[i], Ymin[i], Zmin[i]}); 66 | 67 | draw.drawLine(new double[]{Xmin[i], Ymin[i], Zmax[i]}, new double[]{Xmax[i], Ymin[i], Zmax[i]}); 68 | draw.drawLine(new double[]{Xmax[i], Ymin[i], Zmax[i]}, new double[]{Xmax[i], Ymax[i], Zmax[i]}); 69 | draw.drawLine(new double[]{Xmax[i], Ymax[i], Zmax[i]}, new double[]{Xmin[i], Ymax[i], Zmax[i]}); 70 | draw.drawLine(new double[]{Xmin[i], Ymax[i], Zmax[i]}, new double[]{Xmin[i], Ymin[i], Zmax[i]}); 71 | 72 | draw.drawLine(new double[]{Xmin[i], Ymin[i], Zmin[i]}, new double[]{Xmin[i], Ymin[i], Zmax[i]}); 73 | draw.drawLine(new double[]{Xmax[i], Ymin[i], Zmin[i]}, new double[]{Xmax[i], Ymin[i], Zmax[i]}); 74 | draw.drawLine(new double[]{Xmin[i], Ymax[i], Zmin[i]}, new double[]{Xmin[i], Ymax[i], Zmax[i]}); 75 | draw.drawLine(new double[]{Xmax[i], Ymax[i], Zmin[i]}, new double[]{Xmax[i], Ymax[i], Zmax[i]}); 76 | 77 | draw.drawDot(XY[i]); 78 | } 79 | } 80 | 81 | @Override 82 | public void setData(double[][] d) { 83 | datapanel = null; 84 | XY = d; 85 | } 86 | 87 | @Override 88 | public double[][] getData() { 89 | return XY; 90 | } 91 | 92 | @Override 93 | public double[][] getBounds() { 94 | return new double[][]{{Array.min(Xmin), Array.min(Ymin), Array.min(Zmin)}, {Array.max(Xmax), Array.max(Ymax), Array.max(Zmax)}}; 95 | } 96 | 97 | public void setDataWidth(double[][] w) { 98 | widths = w; 99 | } 100 | 101 | public double[][] getDataWidth() { 102 | return widths; 103 | } 104 | 105 | public void setData(double[][] d, double[][] w) { 106 | setData(d); 107 | widths = w; 108 | } 109 | 110 | public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) { 111 | for (int i = 0; i < XY.length; i++) { 112 | int[] screenCoord = draw.project(XY[i]); 113 | 114 | if ((screenCoord[0] + note_precision > screenCoordTest[0]) && (screenCoord[0] - note_precision < screenCoordTest[0]) 115 | && (screenCoord[1] + note_precision > screenCoordTest[1]) && (screenCoord[1] - note_precision < screenCoordTest[1])) { 116 | return XY[i]; 117 | } 118 | } 119 | return null; 120 | } 121 | 122 | public static void main(String[] args) { 123 | Plot3DPanel plotpanel = new Plot3DPanel(); 124 | for (int i = 0; i < 1; i++) { 125 | double[][] receiverXYZ = new double[100][6]; 126 | for (int j = 0; j < receiverXYZ.length; j++) { 127 | receiverXYZ[j][0] = /*1 + */ Math.random(); 128 | receiverXYZ[j][1] = /*100 * */ Math.random(); 129 | receiverXYZ[j][2] = /*100 * */ Math.random(); 130 | receiverXYZ[j][3] = /*1 + */ Math.random() / 10; 131 | receiverXYZ[j][4] = /*100 * */ Math.random() / 10; 132 | receiverXYZ[j][5] = /*100 * */ Math.random() / 10; 133 | } 134 | int receiverPlotDataIndex = plotpanel.addBoxPlot("Receivers", Color.orange, receiverXYZ); 135 | } 136 | 137 | plotpanel.setLegendOrientation(PlotPanel.SOUTH); 138 | new FrameView(plotpanel).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 139 | } 140 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/CloudPlot2D.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on 13 juil. 07 by richet 3 | */ 4 | package org.math.plot.plots; 5 | 6 | import java.awt.Color; 7 | 8 | import javax.swing.JFrame; 9 | 10 | import org.math.plot.FrameView; 11 | import org.math.plot.Plot2DPanel; 12 | import org.math.plot.PlotPanel; 13 | import org.math.plot.render.AbstractDrawer; 14 | import org.math.plot.utils.Array; 15 | 16 | public class CloudPlot2D extends Plot { 17 | 18 | double[][] NW; 19 | double[][] NE; 20 | double[][] SW; 21 | double[][] SE; 22 | double[] width_constant = {-1, -1}; 23 | double[][] XY; 24 | float[] f; 25 | boolean fill_shape = true; 26 | 27 | public CloudPlot2D(String n, Color c, double[][] _XYcard, double wX, double wY) { 28 | super(n, c); 29 | splitXYf(_XYcard); 30 | width_constant = new double[]{wX, wY}; 31 | 32 | build(); 33 | } 34 | 35 | private void splitXYf(double[][] xycard) { 36 | XY = new double[xycard.length][2]; 37 | f = new float[xycard.length]; 38 | float normf = 0; 39 | for (int i = 0; i < xycard.length; i++) { 40 | XY[i][0] = xycard[i][0]; 41 | XY[i][1] = xycard[i][1]; 42 | f[i] = (float) xycard[i][2]; 43 | normf += f[i];//Math.max(normf, f[i]); 44 | } 45 | 46 | for (int i = 0; i < f.length; i++) { 47 | f[i] = f[i] / normf; 48 | } 49 | 50 | } 51 | 52 | private void build() { 53 | if (width_constant[0] > 0) { 54 | NW = new double[XY.length][]; 55 | NE = new double[XY.length][]; 56 | SW = new double[XY.length][]; 57 | SE = new double[XY.length][]; 58 | for (int i = 0; i < XY.length; i++) { 59 | NW[i] = new double[]{XY[i][0] - width_constant[0] / 2, XY[i][1] + width_constant[1] / 2}; 60 | NE[i] = new double[]{XY[i][0] + width_constant[0] / 2, XY[i][1] + width_constant[1] / 2}; 61 | SW[i] = new double[]{XY[i][0] - width_constant[0] / 2, XY[i][1] - width_constant[1] / 2}; 62 | SE[i] = new double[]{XY[i][0] + width_constant[0] / 2, XY[i][1] - width_constant[1] / 2}; 63 | } 64 | } 65 | } 66 | 67 | public void plot(AbstractDrawer draw, Color c) { 68 | if (!visible) { 69 | return; 70 | } 71 | 72 | draw.canvas.includeInBounds(SW[0]); 73 | draw.canvas.includeInBounds(NE[XY.length - 1]); 74 | 75 | draw.setColor(c); 76 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 77 | for (int i = 0; i < XY.length; i++) { 78 | if (f[i] > 0) { 79 | draw.fillPolygon(f[i], NW[i], NE[i], SE[i], SW[i]); 80 | } 81 | } 82 | } 83 | 84 | @Override 85 | public void setData(double[][] d) { 86 | datapanel = null; 87 | splitXYf(d); 88 | } 89 | 90 | @Override 91 | public double[][] getData() { 92 | return XY; 93 | } 94 | 95 | @Override 96 | public double[][] getBounds() { 97 | double[][] b = new double[][]{Array.min(XY), Array.max(XY)}; 98 | for (int i = 0; i < b[0].length; i++) { 99 | b[0][i] = b[0][i] - width_constant[i] / 2; 100 | b[1][i] = b[1][i] + width_constant[i] / 2; 101 | } 102 | return b; 103 | } 104 | 105 | public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) { 106 | for (int i = 0; i < XY.length; i++) { 107 | int[] screenCoord = draw.project(XY[i]); 108 | 109 | if ((screenCoord[0] + note_precision > screenCoordTest[0]) && (screenCoord[0] - note_precision < screenCoordTest[0]) 110 | && (screenCoord[1] + note_precision > screenCoordTest[1]) && (screenCoord[1] - note_precision < screenCoordTest[1])) { 111 | return XY[i]; 112 | } 113 | } 114 | return null; 115 | } 116 | 117 | public static void main(String[] args) { 118 | Plot2DPanel p = new Plot2DPanel(); 119 | 120 | double[][] cloud = new double[100][2]; 121 | for (int i = 0; i < cloud.length; i++) { 122 | cloud[i][0] = Math.random() + Math.random(); 123 | cloud[i][1] = Math.random() + Math.random(); 124 | } 125 | p.addCloudPlot("cloud", Color.RED, cloud, 5, 5); 126 | 127 | double[][] cloud2 = new double[100][2]; 128 | for (int i = 0; i < cloud2.length; i++) { 129 | cloud2[i][0] = 2 + Math.random() + Math.random(); 130 | cloud2[i][1] = 2 + Math.random() + Math.random(); 131 | } 132 | p.addCloudPlot("cloud2", Color.RED, cloud2, 5, 5); 133 | 134 | p.setLegendOrientation(PlotPanel.SOUTH); 135 | new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/CloudPlot3D.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on 13 juil. 07 by richet 3 | */ 4 | package org.math.plot.plots; 5 | 6 | import java.awt.Color; 7 | 8 | import javax.swing.JFrame; 9 | 10 | import org.math.plot.FrameView; 11 | import org.math.plot.Plot3DPanel; 12 | import org.math.plot.PlotPanel; 13 | import org.math.plot.render.AbstractDrawer; 14 | import org.math.plot.utils.Array; 15 | 16 | public class CloudPlot3D extends Plot { 17 | 18 | double[][] topNW; 19 | double[][] topNE; 20 | double[][] topSW; 21 | double[][] topSE; 22 | double[][] botNW; 23 | double[][] botNE; 24 | double[][] botSW; 25 | double[][] botSE; 26 | double[] width_constant = {-1, -1, -1}; 27 | double[][] XY; 28 | float[] f; 29 | boolean fill_shape = true; 30 | 31 | public CloudPlot3D(String n, Color c, double[][] _XYcard, double wX, double wY, double wZ) { 32 | super(n, c); 33 | splitXYf(_XYcard); 34 | width_constant = new double[]{wX, wY, wZ}; 35 | 36 | build(); 37 | } 38 | 39 | private void splitXYf(double[][] xycard) { 40 | XY = new double[xycard.length][3]; 41 | f = new float[xycard.length]; 42 | float normf = 0; 43 | for (int i = 0; i < xycard.length; i++) { 44 | XY[i][0] = xycard[i][0]; 45 | XY[i][1] = xycard[i][1]; 46 | XY[i][2] = xycard[i][2]; 47 | f[i] = (float) xycard[i][3]; 48 | normf += f[i];//Math.max(normf, f[i]); 49 | } 50 | 51 | for (int i = 0; i < f.length; i++) { 52 | f[i] = f[i] / normf; 53 | } 54 | 55 | } 56 | 57 | private void build() { 58 | if (width_constant[0] > 0) { 59 | topNW = new double[XY.length][]; 60 | topNE = new double[XY.length][]; 61 | topSW = new double[XY.length][]; 62 | topSE = new double[XY.length][]; 63 | botNW = new double[XY.length][]; 64 | botNE = new double[XY.length][]; 65 | botSW = new double[XY.length][]; 66 | botSE = new double[XY.length][]; 67 | for (int i = 0; i < XY.length; i++) { 68 | topNW[i] = new double[]{XY[i][0] - width_constant[0] / 2, XY[i][1] + width_constant[1] / 2, XY[i][2] + width_constant[2] / 2}; 69 | topNE[i] = new double[]{XY[i][0] + width_constant[0] / 2, XY[i][1] + width_constant[1] / 2, XY[i][2] + width_constant[2] / 2}; 70 | topSW[i] = new double[]{XY[i][0] - width_constant[0] / 2, XY[i][1] - width_constant[1] / 2, XY[i][2] + width_constant[2] / 2}; 71 | topSE[i] = new double[]{XY[i][0] + width_constant[0] / 2, XY[i][1] - width_constant[1] / 2, XY[i][2] + width_constant[2] / 2}; 72 | botNW[i] = new double[]{XY[i][0] - width_constant[0] / 2, XY[i][1] + width_constant[1] / 2, XY[i][2] - width_constant[2] / 2}; 73 | botNE[i] = new double[]{XY[i][0] + width_constant[0] / 2, XY[i][1] + width_constant[1] / 2, XY[i][2] - width_constant[2] / 2}; 74 | botSW[i] = new double[]{XY[i][0] - width_constant[0] / 2, XY[i][1] - width_constant[1] / 2, XY[i][2] - width_constant[2] / 2}; 75 | botSE[i] = new double[]{XY[i][0] + width_constant[0] / 2, XY[i][1] - width_constant[1] / 2, XY[i][2] - width_constant[2] / 2}; 76 | } 77 | } 78 | } 79 | 80 | public void plot(AbstractDrawer draw, Color c) { 81 | if (!visible) { 82 | return; 83 | } 84 | 85 | draw.canvas.includeInBounds(botSW[0]); 86 | draw.canvas.includeInBounds(topNE[XY.length - 1]); 87 | 88 | draw.setColor(c); 89 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 90 | for (int i = 0; i < XY.length; i++) { 91 | if (f[i] > 0) { 92 | draw.fillPolygon(f[i], topNW[i], topNE[i], topSE[i], topSW[i]); 93 | draw.fillPolygon(f[i], botNW[i], botNE[i], botSE[i], botSW[i]); 94 | 95 | draw.fillPolygon(f[i], botNW[i], botNE[i], topNE[i], topNW[i]); 96 | draw.fillPolygon(f[i], botSW[i], botSE[i], topSE[i], topSW[i]); 97 | 98 | draw.fillPolygon(f[i], botNW[i], botSW[i], topSW[i], topNW[i]); 99 | draw.fillPolygon(f[i], botNE[i], botSE[i], topSE[i], topNE[i]); 100 | } 101 | } 102 | } 103 | 104 | @Override 105 | public void setData(double[][] d) { 106 | datapanel = null; 107 | splitXYf(d); 108 | } 109 | 110 | @Override 111 | public double[][] getData() { 112 | return XY; 113 | } 114 | 115 | @Override 116 | public double[][] getBounds() { 117 | double[][] b = new double[][]{Array.min(XY), Array.max(XY)}; 118 | for (int i = 0; i < b[0].length; i++) { 119 | b[0][i] = b[0][i] - width_constant[i] / 2; 120 | b[1][i] = b[1][i] + width_constant[i] / 2; 121 | } 122 | return b; 123 | } 124 | 125 | public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) { 126 | for (int i = 0; i < XY.length; i++) { 127 | int[] screenCoord = draw.project(XY[i]); 128 | 129 | if ((screenCoord[0] + note_precision > screenCoordTest[0]) && (screenCoord[0] - note_precision < screenCoordTest[0]) 130 | && (screenCoord[1] + note_precision > screenCoordTest[1]) && (screenCoord[1] - note_precision < screenCoordTest[1])) { 131 | return XY[i]; 132 | } 133 | } 134 | return null; 135 | } 136 | 137 | public static void main(String[] args) { 138 | Plot3DPanel p = new Plot3DPanel(); 139 | 140 | //triangular random cloud (as sum of two uniform random numbers) 141 | double[][] cloud = new double[100][3]; 142 | for (int i = 0; i < cloud.length; i++) { 143 | cloud[i][0] = Math.random() + Math.random(); 144 | cloud[i][1] = Math.random() + Math.random(); 145 | cloud[i][2] = Math.random() + Math.random(); 146 | } 147 | p.addCloudPlot("cloud", Color.RED, cloud, 3, 3, 3); 148 | 149 | double[][] cloud2 = new double[100][3]; 150 | for (int i = 0; i < cloud.length; i++) { 151 | cloud2[i][0] = 2 + Math.random() + Math.random(); 152 | cloud2[i][1] = 2 + Math.random() + Math.random(); 153 | cloud2[i][2] = 2 + Math.random() + Math.random(); 154 | } 155 | p.addCloudPlot("cloud2", Color.RED, cloud2, 3, 3, 3); 156 | 157 | p.setLegendOrientation(PlotPanel.SOUTH); 158 | new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/DensityLayerPlot.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.Color; 4 | 5 | import javax.swing.JFrame; 6 | 7 | import org.math.plot.FrameView; 8 | import org.math.plot.Plot2DPanel; 9 | import org.math.plot.render.AbstractDrawer; 10 | import org.math.plot.utils.Array; 11 | 12 | /** 13 | * @author Yann RICHET 14 | */ 15 | 16 | public class DensityLayerPlot extends LayerPlot { 17 | 18 | public static int WIDTH = 2; 19 | 20 | int axis; 21 | 22 | double[] constant_Q; 23 | 24 | double[][] Q; 25 | 26 | public DensityLayerPlot(Plot p, int a, double[] quantiles) { 27 | this(p, a, new double[0][0]); 28 | constant_Q = quantiles; 29 | } 30 | 31 | /** Build a quantile plot based on given plot. The quantile is drawn as a linear gradient from the base plot dots. 32 | * @param p base plot 33 | * @param a axis number of quantile : 0=X quantile, 1=Y quantile, 2=Z quantile 34 | * @param quantiles array of standard deviation values 35 | */ 36 | public DensityLayerPlot(Plot p, int a, double[][] quantiles) { 37 | super("Density of " + p.name, p); 38 | if (quantiles != null && quantiles.length > 0) 39 | Array.checkRowDimension(quantiles, p.getData().length); 40 | Q = quantiles; 41 | axis = a; 42 | } 43 | 44 | public int getAxe() { 45 | return axis; 46 | } 47 | 48 | public void plot(AbstractDrawer draw, Color c) { 49 | if (!plot.visible) 50 | return; 51 | 52 | draw.setColor(c); 53 | 54 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 55 | draw.setLineWidth(WIDTH); 56 | if (constant_Q == null) 57 | for (int i = 0; i < plot.getData().length; i++) { 58 | 59 | double norm = Double.MAX_VALUE; 60 | for (int j = 0; j < Q[i].length - 1; j++) 61 | norm = Math.min(1 / (Q[i][j + 1] - Q[i][j]), norm); 62 | 63 | double[] d0 = Array.getRowCopy(plot.getData(), i); 64 | double[] d1 = Array.getRowCopy(plot.getData(), i); 65 | double[] d2 = Array.getRowCopy(plot.getData(), i); 66 | 67 | for (int j = 0; j < Q[i].length - 2; j++) { 68 | d1[axis] = d0[axis] + ((Q[i][j] + Q[i][j + 1]) / 2); 69 | d2[axis] = d0[axis] + ((Q[i][j + 1] + Q[i][j + 2]) / 2); 70 | Color c1 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (norm / (Q[i][j + 1] - Q[i][j])))); 71 | Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (norm / (Q[i][j + 2] - Q[i][j + 1])))); 72 | draw.setGradient(d1, c1, d2, c2); 73 | draw.drawLine(d1, d2); 74 | } 75 | } 76 | else { 77 | 78 | double norm = Double.MAX_VALUE; 79 | for (int j = 0; j < constant_Q.length - 1; j++) 80 | norm = Math.min(1 / (constant_Q[j + 1] - constant_Q[j]), norm); 81 | 82 | for (int i = 0; i < plot.getData().length; i++) { 83 | double[] d0 = Array.getRowCopy(plot.getData(), i); 84 | double[] d1 = Array.getRowCopy(plot.getData(), i); 85 | double[] d2 = Array.getRowCopy(plot.getData(), i); 86 | 87 | for (int j = 0; j < constant_Q.length - 2; j++) { 88 | d1[axis] = d0[axis] + (constant_Q[j] + constant_Q[j + 1]) / 2; 89 | d2[axis] = d0[axis] + (constant_Q[j + 1] + constant_Q[j + 2]) / 2; 90 | Color c1 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (norm / (constant_Q[j + 1] - constant_Q[j])))); 91 | Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (norm / (constant_Q[j + 2] - constant_Q[j + 1])))); 92 | draw.setGradient(d1, c1, d2, c2); 93 | draw.drawLine(d1, d2); 94 | } 95 | } 96 | } 97 | draw.resetGradient(); 98 | draw.setLineWidth(AbstractDrawer.DEFAULT_LINE_WIDTH); 99 | 100 | } 101 | 102 | @Override 103 | public void setData(double[][] d) { 104 | //Q = d[0]; 105 | } 106 | 107 | @Override 108 | public double[][] getData() { 109 | return null;//new double[][] { sigma }; 110 | } 111 | 112 | public static void main(String[] args) { 113 | Plot2DPanel p2 = new Plot2DPanel(); 114 | for (int i = 0; i < 2; i++) { 115 | double[][] XYZ = new double[10][2]; 116 | for (int j = 0; j < XYZ.length; j++) { 117 | XYZ[j][0] = /*1 + */Math.random(); 118 | XYZ[j][1] = /*100 * */10 * Math.random(); 119 | } 120 | 121 | p2.addScatterPlot("toto" + i, XYZ); 122 | } 123 | p2.getPlot(0).addQuantiles(1, new double[] {/*-3,-2,*/-4, -2, -0.5, 0, 0.5, 2, 4 /*,2,3*/}); 124 | p2.getPlot(1).addQuantiles(1, new double[] { -3, -2, -1, 0, 1, 2, 3 }); 125 | //p2.getPlot(1).addLayer(new DensityLayerPlot(p2.getPlot(1), 1, new double[] { -.1, 0, .1 })); 126 | 127 | new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 128 | } 129 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/GaussianDensityLayerPlot.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.Color; 4 | 5 | import javax.swing.JFrame; 6 | 7 | import org.math.plot.FrameView; 8 | import org.math.plot.Plot2DPanel; 9 | import org.math.plot.render.AbstractDrawer; 10 | import org.math.plot.utils.Array; 11 | 12 | /** 13 | * @author Yann RICHET 14 | */ 15 | 16 | public class GaussianDensityLayerPlot extends LayerPlot { 17 | 18 | public static int WIDHT = 2; 19 | 20 | int axis; 21 | 22 | Color gradC_0sigma, gradC_1sigma, gradC_2sigma, gradC_3sigma; 23 | 24 | double constant_sigma = 0; 25 | 26 | double[] sigma; 27 | 28 | private float[][] gausspdf_sigma; 29 | 30 | public GaussianDensityLayerPlot(Plot p, int ax, double sigma) { 31 | this(p, ax, null); 32 | constant_sigma = sigma; 33 | 34 | gausspdf_sigma = new float[1][4]; 35 | for (int i = 0; i < gausspdf_sigma.length; i++) 36 | for (int j = 0; j < 4; j++) 37 | gausspdf_sigma[i][j] = (float) (/*1.0 / Math.sqrt(2 * Math.PI * constant_sigma * constant_sigma) */Math.exp(-(j * j) 38 | / (2.0 * constant_sigma * constant_sigma))); 39 | 40 | } 41 | 42 | /*public QuantilePlot(Plot p, int a, double q) { 43 | this(p, a, q, DEFAULT_RATE,true); 44 | }*/ 45 | 46 | /** Build a gauss quantile plot based on given plot. The quantile is drawn as a gaussian gradient from the base plot dots. 47 | * @param p base plot 48 | * @param ax axis number of quantile : 0=X quantile, 1=Y quantile, 2=Z quantile 49 | * @param sigma array of standard deviation values 50 | */ 51 | public GaussianDensityLayerPlot(Plot p, int ax, double[] sigma) { 52 | super("Gauss quantile of " + p.name, p); 53 | if (sigma != null) 54 | Array.checkLength(sigma, p.getData().length); 55 | this.sigma = sigma; 56 | axis = ax; 57 | 58 | if (sigma != null) { 59 | gausspdf_sigma = new float[sigma.length][4]; 60 | for (int i = 0; i < gausspdf_sigma.length; i++) { 61 | for (int j = 0; j < 4; j++) 62 | gausspdf_sigma[i][j] = (float) (/*1.0 / Math.sqrt(2 * Math.PI * sigma[i] * sigma[i]) */Math.exp(-(j * j) / (2.0 * sigma[i] * sigma[i]))); 63 | } 64 | } 65 | 66 | } 67 | 68 | public double getQuantilesValue(int numCoord) { 69 | return sigma[numCoord]; 70 | } 71 | 72 | public int getAxe() { 73 | return axis; 74 | } 75 | 76 | public void plot(AbstractDrawer draw, Color c) { 77 | if (!plot.visible) 78 | return; 79 | 80 | draw.setColor(c); 81 | 82 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 83 | draw.setLineWidth(WIDHT); 84 | if (constant_sigma == 0) 85 | for (int i = 0; i < plot.getData().length; i++) { 86 | gradC_0sigma = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (gausspdf_sigma[i][0]))); 87 | gradC_1sigma = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (gausspdf_sigma[i][1]))); 88 | gradC_2sigma = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (gausspdf_sigma[i][2]))); 89 | gradC_3sigma = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (gausspdf_sigma[i][3]))); 90 | 91 | double[] d = Array.getRowCopy(plot.getData(), i); 92 | double[] d2 = Array.getRowCopy(plot.getData(), i); 93 | d2[axis] += sigma[i]; 94 | draw.setGradient(d, gradC_0sigma, d2, gradC_1sigma); 95 | draw.drawLine(d, d2); 96 | 97 | d[axis] += sigma[i]; 98 | d2[axis] += sigma[i]; 99 | draw.setGradient(d, gradC_1sigma, d2, gradC_2sigma); 100 | draw.drawLine(d, d2); 101 | 102 | d[axis] += sigma[i]; 103 | d2[axis] += sigma[i]; 104 | draw.setGradient(d, gradC_2sigma, d2, gradC_3sigma); 105 | draw.drawLine(d, d2); 106 | 107 | d = Array.getRowCopy(plot.getData(), i); 108 | d2 = Array.getRowCopy(plot.getData(), i); 109 | d2[axis] -= sigma[i]; 110 | draw.setGradient(d2, gradC_1sigma, d, gradC_0sigma); 111 | draw.drawLine(d2, d); 112 | 113 | d[axis] -= sigma[i]; 114 | d2[axis] -= sigma[i]; 115 | draw.setGradient(d2, gradC_2sigma, d, gradC_1sigma); 116 | draw.drawLine(d2, d); 117 | 118 | d[axis] -= sigma[i]; 119 | d2[axis] -= sigma[i]; 120 | draw.setGradient(d2, gradC_3sigma, d, gradC_2sigma); 121 | draw.drawLine(d2, d); 122 | } 123 | else { 124 | gradC_0sigma = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (gausspdf_sigma[0][0]))); 125 | gradC_1sigma = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (gausspdf_sigma[0][1]))); 126 | gradC_2sigma = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (gausspdf_sigma[0][2]))); 127 | gradC_3sigma = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255.0 * (gausspdf_sigma[0][3]))); 128 | 129 | for (int i = 0; i < plot.getData().length; i++) { 130 | 131 | double[] d = Array.getRowCopy(plot.getData(), i); 132 | double[] d2 = Array.getRowCopy(plot.getData(), i); 133 | d2[axis] += constant_sigma; 134 | draw.setGradient(d, gradC_0sigma, d2, gradC_1sigma); 135 | draw.drawLine(d, d2); 136 | 137 | d[axis] += constant_sigma; 138 | d2[axis] += constant_sigma; 139 | draw.setGradient(d, gradC_1sigma, d2, gradC_2sigma); 140 | draw.drawLine(d, d2); 141 | 142 | d[axis] += constant_sigma; 143 | d2[axis] += constant_sigma; 144 | draw.setGradient(d, gradC_2sigma, d2, gradC_3sigma); 145 | draw.drawLine(d, d2); 146 | 147 | d = Array.getRowCopy(plot.getData(), i); 148 | d2 = Array.getRowCopy(plot.getData(), i); 149 | d2[axis] -= constant_sigma; 150 | draw.setGradient(d2, gradC_1sigma, d, gradC_0sigma); 151 | draw.drawLine(d2, d); 152 | 153 | d[axis] -= constant_sigma; 154 | d2[axis] -= constant_sigma; 155 | draw.setGradient(d2, gradC_2sigma, d, gradC_1sigma); 156 | draw.drawLine(d2, d); 157 | 158 | d[axis] -= constant_sigma; 159 | d2[axis] -= constant_sigma; 160 | draw.setGradient(d2, gradC_3sigma, d, gradC_2sigma); 161 | draw.drawLine(d2, d); 162 | } 163 | } 164 | draw.resetGradient(); 165 | draw.setLineWidth(AbstractDrawer.DEFAULT_LINE_WIDTH); 166 | 167 | } 168 | 169 | @Override 170 | public void setData(double[][] d) { 171 | sigma = d[0]; 172 | } 173 | 174 | @Override 175 | public double[][] getData() { 176 | return new double[][] { sigma }; 177 | } 178 | 179 | public static void main(String[] args) { 180 | double[] sXYZ = null; 181 | 182 | Plot2DPanel p2 = new Plot2DPanel(); 183 | for (int i = 0; i < 2; i++) { 184 | double[][] XYZ = new double[10][2]; 185 | sXYZ = new double[10]; 186 | for (int j = 0; j < XYZ.length; j++) { 187 | XYZ[j][0] = /*1 + */Math.random(); 188 | XYZ[j][1] = /*100 * */Math.random(); 189 | sXYZ[j] = /*100 * */Math.random(); 190 | } 191 | 192 | p2.addScatterPlot("toto" + i, XYZ); 193 | } 194 | p2.getPlot(0).addGaussQuantiles(0, sXYZ); 195 | p2.getPlot(1).addGaussQuantiles(1, 0.1); 196 | 197 | new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 198 | } 199 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/GridPlot3D.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on 3 juin 2005 by richet 3 | */ 4 | package org.math.plot.plots; 5 | 6 | import java.awt.*; 7 | 8 | import org.math.plot.*; 9 | import org.math.plot.render.*; 10 | import org.math.plot.utils.Array; 11 | 12 | public class GridPlot3D extends Plot { 13 | 14 | double[] X; 15 | double[] Y; 16 | double[][] Z; 17 | private double[][] XYZ_list; 18 | public boolean draw_lines = true; 19 | public boolean fill_shape = true; 20 | 21 | public GridPlot3D(String n, Color c, double[] _X, double[] _Y, double[][] _Z) { 22 | super(n, c); 23 | X = _X; 24 | Y = _Y; 25 | Z = _Z; 26 | buildXYZ_list(); 27 | } 28 | 29 | public void plot(AbstractDrawer draw, Color c) { 30 | if (!visible) { 31 | return; 32 | } 33 | 34 | draw.setColor(c); 35 | 36 | if (draw_lines) { 37 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 38 | for (int i = 0; i < X.length; i++) { 39 | for (int j = 0; j < Y.length - 1; j++) { 40 | draw.drawLine(new double[]{X[i], Y[j], Z[j][i]}, new double[]{X[i], Y[j + 1], Z[j + 1][i]}); 41 | } 42 | } 43 | 44 | for (int j = 0; j < Y.length; j++) { 45 | for (int i = 0; i < X.length - 1; i++) { 46 | draw.drawLine(new double[]{X[i], Y[j], Z[j][i]}, new double[]{X[i + 1], Y[j], Z[j][i + 1]}); 47 | } 48 | } 49 | } else { 50 | draw.setDotType(AbstractDrawer.ROUND_DOT); 51 | draw.setDotRadius(AbstractDrawer.DEFAULT_DOT_RADIUS); 52 | for (int i = 0; i < X.length; i++) { 53 | for (int j = 0; j < Y.length; j++) { 54 | draw.drawDot(new double[]{X[i], Y[j], Z[j][i]}); 55 | } 56 | } 57 | } 58 | 59 | if (fill_shape) { 60 | for (int j = 0; j < Y.length - 1; j++) { 61 | for (int i = 0; i < X.length - 1; i++) { 62 | draw.fillPolygon(0.2f, new double[]{X[i], Y[j], Z[j][i]}, new double[]{X[i + 1], Y[j], Z[j][i + 1]}, new double[]{X[i + 1], Y[j + 1], 63 | Z[j + 1][i + 1]}, new double[]{X[i], Y[j + 1], Z[j + 1][i]}); 64 | } 65 | } 66 | } 67 | } 68 | 69 | private void buildXYZ_list() { 70 | XYZ_list = new double[X.length * Y.length][3]; 71 | for (int i = 0; i < X.length; i++) { 72 | for (int j = 0; j < Y.length; j++) { 73 | XYZ_list[i + (j) * X.length][0] = X[i]; 74 | XYZ_list[i + (j) * X.length][1] = Y[j]; 75 | XYZ_list[i + (j) * X.length][2] = Z[j][i]; 76 | } 77 | } 78 | } 79 | 80 | @Override 81 | public void setData(double[][] _Z) { 82 | datapanel=null; 83 | Z = _Z; 84 | buildXYZ_list(); 85 | } 86 | 87 | @Override 88 | public double[][] getData() { 89 | return XYZ_list; 90 | } 91 | 92 | @Override 93 | public double[][] getBounds() { 94 | return new double[][]{{Array.min(X), Array.min(Y), Array.min(Array.min(Z))}, {Array.max(X), Array.max(Y), Array.max(Array.min(Z))}}; 95 | } 96 | 97 | public void setDataZ(double[][] _Z) { 98 | setData(_Z); 99 | } 100 | 101 | public double[][] getDataZ() { 102 | return Z; 103 | } 104 | 105 | public void setDataX(double[] _X) { 106 | datapanel=null; 107 | X = _X; 108 | buildXYZ_list(); 109 | } 110 | 111 | public double[] getDataX() { 112 | return X; 113 | } 114 | 115 | public void setDataY(double[] _Y) { 116 | datapanel=null; 117 | Y = _Y; 118 | buildXYZ_list(); 119 | } 120 | 121 | public double[] getDataY() { 122 | return Y; 123 | } 124 | 125 | public void setDataXYZ(double[] _X, double[] _Y, double[][] _Z) { 126 | datapanel=null; 127 | X = _X; 128 | Y = _Y; 129 | Z = _Z; 130 | buildXYZ_list(); 131 | } 132 | 133 | public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) { 134 | for (int i = 0; i < X.length; i++) { 135 | for (int j = 0; j < Y.length; j++) { 136 | double[] XY = {X[i], Y[j], Z[j][i]}; 137 | int[] screenCoord = draw.project(XY); 138 | 139 | if ((screenCoord[0] + note_precision > screenCoordTest[0]) && (screenCoord[0] - note_precision < screenCoordTest[0]) 140 | && (screenCoord[1] + note_precision > screenCoordTest[1]) && (screenCoord[1] - note_precision < screenCoordTest[1])) { 141 | return XY; 142 | } 143 | } 144 | } 145 | return null; 146 | } 147 | 148 | public static void main(String[] args) { 149 | 150 | int n = 14; 151 | int m = 16; 152 | Plot3DPanel p = new Plot3DPanel(); 153 | double[] X = new double[n]; 154 | double[] Y = new double[m]; 155 | double[][] Z = new double[m][n]; 156 | 157 | for (int i = 0; i < X.length; i++) { 158 | X[i] = 3 + i / (double) X.length; 159 | for (int j = 0; j < Y.length; j++) { 160 | Y[j] = 5 + j / (double) Y.length; 161 | Z[j][i] = Math.exp(X[i]) + Y[j]; 162 | } 163 | } 164 | p.addGridPlot("toto", X, Y, Z); 165 | 166 | p.setLegendOrientation(PlotPanel.SOUTH); 167 | new FrameView(p); 168 | } 169 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/HistogramPlot2D.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.*; 4 | 5 | import org.math.plot.*; 6 | import org.math.plot.render.*; 7 | import org.math.plot.utils.Array; 8 | 9 | public class HistogramPlot2D extends Plot { 10 | 11 | double[][] topLeft; 12 | double[][] topRight; 13 | double[][] bottomLeft; 14 | double[][] bottomRight; 15 | double[] widths; 16 | double width_constant = -1; 17 | double offsetCenter_perWidth; 18 | double factorWidth; 19 | boolean autowidth; 20 | boolean fill_shape = true; 21 | double[][] XY; 22 | 23 | public HistogramPlot2D(String n, Color c, double[][] _XY, double w) { 24 | this(n, c, _XY, w, 0.5, 1); 25 | } 26 | 27 | public HistogramPlot2D(String n, Color c, double[][] _XY, double[] w) { 28 | this(n, c, _XY, w, 0.5, 1); 29 | } 30 | 31 | // TODO Histogram group plots 32 | public HistogramPlot2D(String n, Color c, double[][] _XY, double w, double _offsetCenter_perWidth, double _factorWidth) { 33 | super(n, c); 34 | XY = _XY; 35 | width_constant = w; 36 | 37 | autowidth = false; 38 | offsetCenter_perWidth = _offsetCenter_perWidth; 39 | factorWidth = _factorWidth; 40 | 41 | build(); 42 | } 43 | 44 | public HistogramPlot2D(String n, Color c, double[][] _XY, double[] w, double _offsetCenter_perWidth, double _factorWidth) { 45 | super(n, c); 46 | XY = _XY; 47 | widths = w; 48 | 49 | autowidth = false; 50 | offsetCenter_perWidth = _offsetCenter_perWidth; 51 | factorWidth = _factorWidth; 52 | 53 | build(); 54 | } 55 | 56 | private void build() { 57 | if (width_constant > 0) { 58 | topLeft = new double[XY.length][]; 59 | topRight = new double[XY.length][]; 60 | bottomLeft = new double[XY.length][]; 61 | bottomRight = new double[XY.length][]; 62 | for (int i = 0; i < XY.length; i++) { 63 | topLeft[i] = new double[]{XY[i][0] - factorWidth * width_constant / 2 + (offsetCenter_perWidth - 0.5) * width_constant, XY[i][1]}; 64 | topRight[i] = new double[]{XY[i][0] + factorWidth * width_constant / 2 + (offsetCenter_perWidth - 0.5) * width_constant, XY[i][1]}; 65 | bottomLeft[i] = new double[]{XY[i][0] - factorWidth * width_constant / 2 + (offsetCenter_perWidth - 0.5) * width_constant, 0}; 66 | bottomRight[i] = new double[]{XY[i][0] + factorWidth * width_constant / 2 + (offsetCenter_perWidth - 0.5) * width_constant, 0}; 67 | } 68 | } else { 69 | topLeft = new double[XY.length][]; 70 | topRight = new double[XY.length][]; 71 | bottomLeft = new double[XY.length][]; 72 | bottomRight = new double[XY.length][]; 73 | for (int i = 0; i < XY.length; i++) { 74 | topLeft[i] = new double[]{XY[i][0] - factorWidth * widths[i] / 2 + (offsetCenter_perWidth - 0.5) * widths[i], XY[i][1]}; 75 | topRight[i] = new double[]{XY[i][0] + factorWidth * widths[i] / 2 + (offsetCenter_perWidth - 0.5) * widths[i], XY[i][1]}; 76 | bottomLeft[i] = new double[]{XY[i][0] - factorWidth * widths[i] / 2 + (offsetCenter_perWidth - 0.5) * widths[i], 0}; 77 | bottomRight[i] = new double[]{XY[i][0] + factorWidth * widths[i] / 2 + (offsetCenter_perWidth - 0.5) * widths[i], 0}; 78 | } 79 | } 80 | } 81 | 82 | /* 83 | * public HistogramPlot2D(double[][] XY, Color c, String n, ProjectionBase 84 | * b) { super(XY, c, n, PlotPanel.HISTOGRAM, b); 85 | * 86 | * autowidth = true; 87 | * 88 | * topLeft = new double[datas.length][]; topRight = new 89 | * double[datas.length][]; bottomLeft = new double[datas.length][]; 90 | * bottomRight = new double[datas.length][]; 91 | * 92 | * Sorting sort = new Sorting(DoubleArray.getColumnCopy(datas, 0), false); 93 | * datas = DoubleArray.getRowsCopy(XY, sort.getIndex()); 94 | * 95 | * topLeft[0] = new double[] { datas[0][0] + (datas[0][0] - datas[1][0]) / 96 | * 2, datas[0][1] }; topRight[0] = new double[] { (datas[0][0] + 97 | * datas[1][0]) / 2, datas[0][1] }; bottomLeft[0] = new double[] { 98 | * datas[0][0] + (datas[0][0] - datas[1][0]) / 2, 0 }; bottomRight[0] = new 99 | * double[] { (datas[0][0] + datas[1][0]) / 2, 0 }; for (int i = 1; i < 100 | * datas.length - 1; i++) { topLeft[i] = new double[] { (datas[i][0] + 101 | * datas[i - 1][0]) / 2, datas[i][1] }; topRight[i] = new double[] { 102 | * (datas[i][0] + datas[i + 1][0]) / 2, datas[i][1] }; bottomLeft[i] = new 103 | * double[] { (datas[i][0] + datas[i - 1][0]) / 2, 0 }; bottomRight[i] = new 104 | * double[] { (datas[i][0] + datas[i + 1][0]) / 2, 0 }; } 105 | * topLeft[datas.length - 1] = new double[] { (datas[datas.length - 1][0] + 106 | * datas[datas.length - 2][0]) / 2, datas[datas.length - 1][1] }; 107 | * topRight[datas.length - 1] = new double[] { datas[datas.length - 1][0] + 108 | * (datas[datas.length - 1][0] - datas[datas.length - 2][0]) / 2, 109 | * datas[datas.length - 1][1] }; bottomLeft[datas.length - 1] = new double[] { 110 | * (datas[datas.length - 1][0] + datas[datas.length - 2][0]) / 2, 0 }; 111 | * bottomRight[datas.length - 1] = new double[] { datas[datas.length - 1][0] + 112 | * (datas[datas.length - 1][0] - datas[datas.length - 2][0]) / 2, 0 }; } 113 | */ 114 | public void plot(AbstractDrawer draw, Color c) { 115 | if (!visible) { 116 | return; 117 | } 118 | 119 | draw.setColor(c); 120 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 121 | for (int i = 0; i < XY.length; i++) { 122 | draw.drawLine(bottomLeft[i], topLeft[i]); 123 | draw.drawLine(topLeft[i], topRight[i]); 124 | draw.drawLine(topRight[i], bottomRight[i]); 125 | draw.drawLine(bottomRight[i], bottomLeft[i]); 126 | 127 | if (fill_shape) { 128 | draw.fillPolygon(0.2f, bottomLeft[i], topLeft[i], topRight[i], bottomRight[i]); 129 | } 130 | } 131 | } 132 | 133 | @Override 134 | public void setData(double[][] d) { 135 | datapanel = null; 136 | XY = d; 137 | } 138 | 139 | @Override 140 | public double[][] getData() { 141 | return XY; 142 | } 143 | 144 | @Override 145 | public double[][] getBounds() { 146 | return new double[][]{Array.min(bottomLeft), Array.max(topRight)}; 147 | } 148 | 149 | public void setDataWidth(double[] w) { 150 | widths = w; 151 | width_constant = -1; 152 | build(); 153 | } 154 | 155 | public void setDataWidth(double w) { 156 | width_constant = w; 157 | build(); 158 | } 159 | 160 | public double[] getDataWidth() { 161 | if (width_constant > 0) { 162 | widths = new double[XY.length]; 163 | for (int i = 0; i < widths.length; i++) { 164 | widths[i] = width_constant; 165 | } 166 | } 167 | return widths; 168 | } 169 | 170 | public void setData(double[][] d, double[] w) { 171 | setData(d); 172 | setDataWidth(w); 173 | } 174 | 175 | public void setData(double[][] d, double w) { 176 | setData(d); 177 | setDataWidth(w); 178 | } 179 | 180 | public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) { 181 | for (int i = 0; i < XY.length; i++) { 182 | int[] screenCoord = draw.project(XY[i]); 183 | 184 | if ((screenCoord[0] + note_precision > screenCoordTest[0]) && (screenCoord[0] - note_precision < screenCoordTest[0]) 185 | && (screenCoord[1] + note_precision > screenCoordTest[1]) && (screenCoord[1] - note_precision < screenCoordTest[1])) { 186 | return XY[i]; 187 | } 188 | } 189 | return null; 190 | } 191 | 192 | public static void main(String[] args) { 193 | double[] X = new double[500]; 194 | for (int i = 0; i < X.length; i++) { 195 | X[i] = Math.random() + Math.random(); 196 | } 197 | Plot2DPanel p = new Plot2DPanel("SOUTH"); 198 | p.addHistogramPlot("test", X, 10); 199 | new FrameView(p); 200 | } 201 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/HistogramPlot3D.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.*; 4 | 5 | import org.math.plot.*; 6 | import org.math.plot.render.*; 7 | import org.math.plot.utils.Array; 8 | 9 | public class HistogramPlot3D extends Plot { 10 | 11 | double[][] topNW; 12 | double[][] topNE; 13 | double[][] topSW; 14 | double[][] topSE; 15 | double[][] bottomNW; 16 | double[][] bottomNE; 17 | double[][] bottomSW; 18 | double[][] bottomSE; 19 | double[][] widths; 20 | double[] width_constant = {-1, -1}; 21 | double[][] XY; 22 | boolean fill_shape = true; 23 | 24 | public HistogramPlot3D(String n, Color c, double[][] _XY, double[][] w) { 25 | super(n, c); 26 | XY = _XY; 27 | widths = w; 28 | 29 | build(); 30 | } 31 | 32 | public HistogramPlot3D(String n, Color c, double[][] _XY, double wX, double wY) { 33 | super(n, c); 34 | XY = _XY; 35 | width_constant = new double[]{wX, wY}; 36 | 37 | build(); 38 | } 39 | 40 | public HistogramPlot3D(String n, Color c, double[][] _XY, double[] w) { 41 | super(n, c); 42 | XY = _XY; 43 | width_constant = w; 44 | 45 | build(); 46 | } 47 | 48 | private void build() { 49 | if (width_constant[0] > 0) { 50 | topNW = new double[XY.length][]; 51 | topNE = new double[XY.length][]; 52 | topSW = new double[XY.length][]; 53 | topSE = new double[XY.length][]; 54 | bottomNW = new double[XY.length][]; 55 | bottomNE = new double[XY.length][]; 56 | bottomSW = new double[XY.length][]; 57 | bottomSE = new double[XY.length][]; 58 | for (int i = 0; i < XY.length; i++) { 59 | topNW[i] = new double[]{XY[i][0] - width_constant[0] / 2, XY[i][1] + width_constant[1] / 2, XY[i][2]}; 60 | topNE[i] = new double[]{XY[i][0] + width_constant[0] / 2, XY[i][1] + width_constant[1] / 2, XY[i][2]}; 61 | topSW[i] = new double[]{XY[i][0] - width_constant[0] / 2, XY[i][1] - width_constant[1] / 2, XY[i][2]}; 62 | topSE[i] = new double[]{XY[i][0] + width_constant[0] / 2, XY[i][1] - width_constant[1] / 2, XY[i][2]}; 63 | bottomNW[i] = new double[]{XY[i][0] - width_constant[0] / 2, XY[i][1] + width_constant[1] / 2, 0}; 64 | bottomNE[i] = new double[]{XY[i][0] + width_constant[0] / 2, XY[i][1] + width_constant[1] / 2, 0}; 65 | bottomSW[i] = new double[]{XY[i][0] - width_constant[0] / 2, XY[i][1] - width_constant[1] / 2, 0}; 66 | bottomSE[i] = new double[]{XY[i][0] + width_constant[0] / 2, XY[i][1] - width_constant[1] / 2, 0}; 67 | } 68 | } else { 69 | topNW = new double[XY.length][]; 70 | topNE = new double[XY.length][]; 71 | topSW = new double[XY.length][]; 72 | topSE = new double[XY.length][]; 73 | bottomNW = new double[XY.length][]; 74 | bottomNE = new double[XY.length][]; 75 | bottomSW = new double[XY.length][]; 76 | bottomSE = new double[XY.length][]; 77 | for (int i = 0; i < XY.length; i++) { 78 | topNW[i] = new double[]{XY[i][0] - widths[i][0] / 2, XY[i][1] + widths[i][1] / 2, XY[i][2]}; 79 | topNE[i] = new double[]{XY[i][0] + widths[i][0] / 2, XY[i][1] + widths[i][1] / 2, XY[i][2]}; 80 | topSW[i] = new double[]{XY[i][0] - widths[i][0] / 2, XY[i][1] - widths[i][1] / 2, XY[i][2]}; 81 | topSE[i] = new double[]{XY[i][0] + widths[i][0] / 2, XY[i][1] - widths[i][1] / 2, XY[i][2]}; 82 | bottomNW[i] = new double[]{XY[i][0] - widths[i][0] / 2, XY[i][1] + widths[i][1] / 2, 0}; 83 | bottomNE[i] = new double[]{XY[i][0] + widths[i][0] / 2, XY[i][1] + widths[i][1] / 2, 0}; 84 | bottomSW[i] = new double[]{XY[i][0] - widths[i][0] / 2, XY[i][1] - widths[i][1] / 2, 0}; 85 | bottomSE[i] = new double[]{XY[i][0] + widths[i][0] / 2, XY[i][1] - widths[i][1] / 2, 0}; 86 | } 87 | } 88 | } 89 | 90 | public void plot(AbstractDrawer draw, Color c) { 91 | if (!visible) { 92 | return; 93 | } 94 | 95 | draw.canvas.includeInBounds(bottomSW[0]); 96 | draw.canvas.includeInBounds(topNE[XY.length - 1]); 97 | 98 | draw.setColor(c); 99 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 100 | for (int i = 0; i < XY.length; i++) { 101 | if (topNW[i][2] != bottomNW[i][2]) { 102 | draw.drawLine(topNW[i], topNE[i]); 103 | draw.drawLine(topNE[i], topSE[i]); 104 | draw.drawLine(topSE[i], topSW[i]); 105 | draw.drawLine(topSW[i], topNW[i]); 106 | 107 | draw.drawLine(bottomNW[i], bottomNE[i]); 108 | draw.drawLine(bottomNE[i], bottomSE[i]); 109 | draw.drawLine(bottomSE[i], bottomSW[i]); 110 | draw.drawLine(bottomSW[i], bottomNW[i]); 111 | 112 | draw.drawLine(bottomNW[i], topNW[i]); 113 | draw.drawLine(bottomNE[i], topNE[i]); 114 | draw.drawLine(bottomSE[i], topSE[i]); 115 | draw.drawLine(bottomSW[i], topSW[i]); 116 | 117 | if (fill_shape) { 118 | draw.fillPolygon(0.2f, topNW[i], topNE[i], topSE[i], topSW[i]); 119 | //draw.fillPolygon(bottomNW[i], bottomNE[i], bottomSE[i], bottomSW[i]); 120 | /*draw.fillPolygon(topNW[i], topNE[i], bottomNE[i], bottomNW[i]); 121 | draw.fillPolygon(topSW[i], topSE[i], bottomSE[i], bottomSW[i]); 122 | draw.fillPolygon(topNE[i], topSE[i], bottomSE[i], bottomNE[i]); 123 | draw.fillPolygon(topNW[i], topSW[i], bottomSW[i], bottomNW[i]);*/ 124 | } 125 | } 126 | } 127 | } 128 | 129 | @Override 130 | public void setData(double[][] d) { 131 | datapanel = null; 132 | XY = d; 133 | } 134 | 135 | @Override 136 | public double[][] getData() { 137 | return XY; 138 | } 139 | 140 | @Override 141 | public double[][] getBounds() { 142 | return new double[][]{Array.min(bottomSW), Array.max(topNE)}; 143 | } 144 | 145 | public void setDataWidth(double[][] w) { 146 | widths = w; 147 | } 148 | 149 | public void setDataWidth(double... w) { 150 | width_constant = w; 151 | build(); 152 | } 153 | 154 | public double[][] getDataWidth() { 155 | if (width_constant[0] > 0) { 156 | widths = new double[XY.length][2]; 157 | for (int i = 0; i < widths.length; i++) { 158 | widths[i][0] = width_constant[0]; 159 | widths[i][1] = width_constant[1]; 160 | } 161 | } 162 | return widths; 163 | } 164 | 165 | public void setData(double[][] d, double[][] w) { 166 | setData(d); 167 | widths = w; 168 | } 169 | 170 | public void setData(double[][] d, double... w) { 171 | setData(d); 172 | setDataWidth(w); 173 | } 174 | 175 | public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) { 176 | for (int i = 0; i < XY.length; i++) { 177 | int[] screenCoord = draw.project(XY[i]); 178 | 179 | if ((screenCoord[0] + note_precision > screenCoordTest[0]) && (screenCoord[0] - note_precision < screenCoordTest[0]) 180 | && (screenCoord[1] + note_precision > screenCoordTest[1]) && (screenCoord[1] - note_precision < screenCoordTest[1])) { 181 | return XY[i]; 182 | } 183 | } 184 | return null; 185 | } 186 | 187 | public static void main(String[] args) { 188 | double[][] XY = new double[500][2]; 189 | for (int i = 0; i < XY.length; i++) { 190 | XY[i][0] = Math.random() + Math.random(); 191 | XY[i][1] = Math.random() + Math.random(); 192 | } 193 | Plot3DPanel p = new Plot3DPanel("SOUTH"); 194 | p.addHistogramPlot("test", XY, 4, 6); 195 | new FrameView(p); 196 | } 197 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/LayerPlot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on 5 juil. 07 by richet 3 | */ 4 | package org.math.plot.plots; 5 | 6 | import org.math.plot.DataPanel; 7 | import org.math.plot.canvas.PlotCanvas; 8 | import org.math.plot.render.*; 9 | 10 | public abstract class LayerPlot extends Plot { 11 | 12 | Plot plot; 13 | 14 | public LayerPlot(String name, Plot p) { 15 | super(name, p.color); 16 | plot = p; 17 | } 18 | 19 | public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) { 20 | return null; 21 | } 22 | 23 | @Override 24 | public double[][] getBounds() { 25 | return plot.getBounds(); 26 | } 27 | 28 | @Override 29 | public DataPanel getDataPanel(PlotCanvas plotCanvas) { 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/LinePlot.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.*; 4 | 5 | import javax.swing.*; 6 | 7 | import org.math.plot.*; 8 | import org.math.plot.render.*; 9 | 10 | public class LinePlot extends ScatterPlot { 11 | 12 | public boolean draw_dot = false; 13 | 14 | public LinePlot(String n, Color c, boolean[][] _pattern, double[][] _XY) { 15 | super(n, c, _pattern, _XY); 16 | } 17 | 18 | public LinePlot(String n, Color c, int _type, int _radius, double[][] _XY) { 19 | super(n, c, _type, _radius, _XY); 20 | } 21 | 22 | public LinePlot(String n, Color c, double[][] _XY) { 23 | super(n, c, _XY); 24 | } 25 | 26 | public void plot(AbstractDrawer draw, Color c) { 27 | if (!visible) 28 | return; 29 | 30 | if (draw_dot) 31 | super.plot(draw, c); 32 | 33 | draw.setColor(c); 34 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 35 | for (int i = 0; i < XY.length - 1; i++) 36 | if (!anyNaN(XY[i]) && !anyNaN(XY[i+1])) 37 | draw.drawLine(XY[i], XY[i + 1]); 38 | } 39 | 40 | boolean anyNaN(double[] xy) { 41 | for (int i = 0; i < xy.length; i++) { 42 | if(Double.isNaN(xy[i])) return true; 43 | } 44 | return false; 45 | } 46 | 47 | public static void main(String[] args) { 48 | Plot2DPanel p2 = new Plot2DPanel(); 49 | 50 | double[][] XYZ = new double[100][2]; 51 | for (int j = 0; j < XYZ.length; j++) { 52 | XYZ[j][0] = 2*Math.PI*(double)j/XYZ.length; 53 | XYZ[j][1] = Math.sin(XYZ[j][0]); 54 | } 55 | XYZ[50][0] = Double.NaN; 56 | p2.addLinePlot("sin" , XYZ); 57 | 58 | 59 | p2.setLegendOrientation(PlotPanel.SOUTH); 60 | new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 61 | 62 | Plot3DPanel p = new Plot3DPanel(); 63 | 64 | XYZ = new double[100][3]; 65 | for (int j = 0; j < XYZ.length; j++) { 66 | XYZ[j][0] = 2*Math.PI*(double)j/XYZ.length; 67 | XYZ[j][1] = Math.sin(XYZ[j][0]); 68 | XYZ[j][2] = Math.sin(XYZ[j][0])*Math.cos(XYZ[j][1]); 69 | } 70 | p.addLinePlot("toto" , XYZ); 71 | 72 | p.setLegendOrientation(PlotPanel.SOUTH); 73 | new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/QuantileLayerPlot.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.Color; 4 | 5 | import javax.swing.JFrame; 6 | 7 | import org.math.plot.FrameView; 8 | import org.math.plot.Plot2DPanel; 9 | import org.math.plot.render.AbstractDrawer; 10 | import org.math.plot.utils.Array; 11 | 12 | /** 13 | * @author Yann RICHET 14 | * @version 1.0 15 | */ 16 | 17 | public class QuantileLayerPlot extends LayerPlot { 18 | 19 | public static int WIDTH = 2; 20 | 21 | int axe; 22 | 23 | double quantileRate; 24 | 25 | Color gradC; 26 | 27 | double main_data_constant = 0; 28 | 29 | public boolean symetric = false; 30 | 31 | double[] Q; 32 | 33 | //public static double DEFAULT_RATE=1.0; 34 | 35 | /*public QuantilePlot(Plot p, int a, double[] q, boolean _symetric) { 36 | this(p, a, q, DEFAULT_RATE,_symetric); 37 | 38 | }*/ 39 | 40 | public QuantileLayerPlot(Plot p, int a, double q, double r, boolean _symetric) { 41 | this(p, a, null, r, true); 42 | main_data_constant = q; 43 | } 44 | 45 | /*public QuantilePlot(Plot p, int a, double q) { 46 | this(p, a, q, DEFAULT_RATE,true); 47 | }*/ 48 | 49 | /** Build a quantile plot based on given plot. The quantile is drawn as a linear gradient from the base plot dots. 50 | * @param p base plot 51 | * @param a axis number of quantile : 0=X quantile, 1=Y quantile, 2=Z quantile 52 | * @param q array of quantiles values 53 | * @param r rate of the quantile. The gradient line length is q/r 54 | * @param _symetric if yes, quantiles are drawn on both negative and positive sides of base plot dots 55 | */ 56 | public QuantileLayerPlot(Plot p, int a, double[] q, double r, boolean _symetric) { 57 | super(r + " quantile of " + p.name, p); 58 | if (q != null) 59 | Array.checkLength(q, p.getData().length); 60 | Q = q; 61 | axe = a; 62 | quantileRate = r; 63 | symetric = _symetric; 64 | 65 | } 66 | 67 | public double getQuantilesValue(int numCoord) { 68 | return Q[numCoord]; 69 | } 70 | 71 | public int getAxe() { 72 | return axe; 73 | } 74 | 75 | public double getQuantileRate() { 76 | return quantileRate; 77 | } 78 | 79 | public void plot(AbstractDrawer draw, Color c) { 80 | if (!plot.visible) 81 | return; 82 | 83 | draw.setColor(c); 84 | gradC = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255 * (1 - quantileRate))); 85 | 86 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 87 | draw.setLineWidth(WIDTH); 88 | if (main_data_constant == 0) 89 | for (int i = 0; i < plot.getData().length; i++) { 90 | double[] d = Array.getRowCopy(plot.getData(), i); 91 | d[axe] += Q[i];///quantileRate; 92 | draw.setGradient(plot.getData()[i], c, d, gradC); 93 | draw.drawLine(plot.getData()[i], d); 94 | // draw.drawDot(d, RADIUS/*(int)(RADIUS*quantileRate)*/); 95 | 96 | if (symetric) { 97 | d[axe] -= 2 * Q[i];///quantileRate; 98 | draw.setGradient(plot.getData()[i], c, d, gradC); 99 | draw.drawLine(plot.getData()[i], d); 100 | // draw.drawDot(d, RADIUS/*(int)(RADIUS*quantileRate)*/); 101 | } 102 | } 103 | else 104 | for (int i = 0; i < plot.getData().length; i++) { 105 | double[] d = Array.getRowCopy(plot.getData(), i); 106 | d[axe] += main_data_constant;///quantileRate; 107 | draw.setGradient(plot.getData()[i], c, d, gradC); 108 | draw.drawLine(plot.getData()[i], d); 109 | // draw.drawDot(d, shape/*RADIUS/*(int)(RADIUS*quantileRate)*/); 110 | 111 | if (symetric) { 112 | d[axe] -= 2 * main_data_constant;///quantileRate; 113 | draw.setGradient(plot.getData()[i], c, d, gradC); 114 | draw.drawLine(plot.getData()[i], d); 115 | // draw.drawDot(d, RADIUS/*(int)(RADIUS*quantileRate)*/); 116 | } 117 | } 118 | draw.resetGradient(); 119 | draw.setLineWidth(AbstractDrawer.DEFAULT_LINE_WIDTH); 120 | 121 | } 122 | 123 | @Override 124 | public void setData(double[][] d) { 125 | Q = d[0]; 126 | } 127 | 128 | @Override 129 | public double[][] getData() { 130 | return new double[][] { Q }; 131 | } 132 | 133 | public static void main(String[] args) { 134 | Plot2DPanel p2 = new Plot2DPanel(); 135 | for (int i = 0; i < 1; i++) { 136 | double[][] XYZ = new double[10][2]; 137 | for (int j = 0; j < XYZ.length; j++) { 138 | XYZ[j][0] = /*1 + */Math.random(); 139 | XYZ[j][1] = /*100 * */Math.random(); 140 | } 141 | p2.addScatterPlot("toto" + i, XYZ); 142 | } 143 | p2.addQuantiletoPlot(0, 1, 1.0, true, 0.2); 144 | new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 145 | } 146 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/ScatterPlot.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.*; 4 | 5 | import javax.swing.*; 6 | 7 | import org.math.plot.*; 8 | import org.math.plot.canvas.PlotCanvas; 9 | import org.math.plot.render.*; 10 | import org.math.plot.utils.Array; 11 | import org.math.plot.utils.FastMath; 12 | 13 | public class ScatterPlot extends Plot { 14 | 15 | private int type; 16 | private int radius; 17 | private boolean[][] pattern; 18 | private boolean use_pattern; 19 | double[][] XY; 20 | private String[] tags; 21 | 22 | public ScatterPlot(String n, Color c, boolean[][] _pattern, double[][] _XY) { 23 | super(n, c); 24 | XY = _XY; 25 | use_pattern = true; 26 | pattern = _pattern; 27 | } 28 | 29 | public ScatterPlot(String n, Color c, int _type, int _radius, double[][] _XY) { 30 | super(n, c); 31 | XY = _XY; 32 | use_pattern = false; 33 | type = _type; 34 | radius = _radius; 35 | } 36 | 37 | public ScatterPlot(String n, Color c, double[][] _XY) { 38 | this(n, c, AbstractDrawer.ROUND_DOT, AbstractDrawer.DEFAULT_DOT_RADIUS, _XY); 39 | } 40 | 41 | public void plot(AbstractDrawer draw, Color c) { 42 | if (!visible) { 43 | return; 44 | } 45 | 46 | draw.setColor(c); 47 | if (use_pattern) { 48 | draw.setDotType(AbstractDrawer.PATTERN_DOT); 49 | draw.setDotPattern(pattern); 50 | } else { 51 | draw.setDotRadius(radius); 52 | if (type == AbstractDrawer.CROSS_DOT) { 53 | draw.setDotType(AbstractDrawer.CROSS_DOT); 54 | } else { 55 | draw.setDotType(AbstractDrawer.ROUND_DOT); 56 | } 57 | } 58 | 59 | for (int i = 0; i < XY.length; i++) { 60 | draw.drawDot(XY[i]); 61 | } 62 | } 63 | 64 | public void setDotPattern(int t) { 65 | type = t; 66 | use_pattern = false; 67 | } 68 | 69 | public void setDotPattern(boolean[][] t) { 70 | use_pattern = true; 71 | pattern = t; 72 | } 73 | 74 | @Override 75 | public void setData(double[][] d) { 76 | datapanel = null; 77 | XY = d; 78 | } 79 | 80 | @Override 81 | public double[][] getData() { 82 | return XY; 83 | } 84 | 85 | @Override 86 | public double[][] getBounds() { 87 | return Array.mergeRows(Array.min(XY), Array.max(XY)); 88 | } 89 | 90 | public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) { 91 | for (int i = 0; i < XY.length; i++) { 92 | int[] screenCoord = draw.project(XY[i]); 93 | 94 | if (FastMath.abs(screenCoord[0] - screenCoordTest[0]) < note_precision && FastMath.abs(screenCoord[1] - screenCoordTest[1]) < note_precision) { 95 | return XY[i]; 96 | } 97 | } 98 | return null; 99 | } 100 | 101 | public static void main(String[] args) { 102 | Plot2DPanel p2 = new Plot2DPanel(); 103 | for (int i = 0; i < 3; i++) { 104 | double[][] XYZ = new double[10][2]; 105 | for (int j = 0; j < XYZ.length; j++) { 106 | XYZ[j][0] = /*1 + */ Math.random(); 107 | XYZ[j][1] = /*100 * */ Math.random(); 108 | } 109 | p2.addScatterPlot("toto" + i, XYZ); 110 | } 111 | 112 | p2.setLegendOrientation(PlotPanel.SOUTH); 113 | new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 114 | 115 | Plot3DPanel p = new Plot3DPanel(); 116 | String[] tags = null; 117 | for (int i = 0; i < 3; i++) { 118 | double[][] XYZ = new double[10][3]; 119 | tags = new String[10]; 120 | for (int j = 0; j < XYZ.length; j++) { 121 | XYZ[j][0] = /*1 +*/ 2.5 * Math.random(); 122 | XYZ[j][1] = /*100 **/ Math.random(); 123 | XYZ[j][2] = /*0.0001 **/ Math.random(); 124 | tags[j] = "tags " + j; 125 | } 126 | p.addScatterPlot("toto" + i, XYZ); 127 | } 128 | ((ScatterPlot) p.getPlot(0)).setTags(tags); 129 | 130 | p.setLegendOrientation(PlotPanel.SOUTH); 131 | new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 132 | } 133 | 134 | /** 135 | * @param tags the tags to set 136 | */ 137 | public void setTags(String[] tags) { 138 | datapanel = null; 139 | this.tags = tags; 140 | } 141 | 142 | @Override 143 | public void noteCoord(AbstractDrawer draw, double[] coordNoted) { 144 | if (coordNoted == null) { 145 | return; 146 | } 147 | 148 | if (tags == null) { 149 | super.noteCoord(draw, coordNoted); 150 | } else { 151 | draw.setColor(PlotCanvas.NOTE_COLOR); 152 | for (int i = 0; i < XY.length; i++) { 153 | if (tags.length > i) { 154 | if (Array.equals(XY[i], coordNoted)) { 155 | draw.drawShadowedText(tags[i], .5f, coordNoted); 156 | } 157 | } 158 | } 159 | } 160 | //draw.drawCoordinate(coordNoted); 161 | //draw.drawText(Array.cat(draw.canvas.reverseMapedData(coordNoted)), coordNoted); 162 | } 163 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/StaircasePlot.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.*; 4 | 5 | import javax.swing.*; 6 | 7 | import org.math.plot.*; 8 | import org.math.plot.render.*; 9 | 10 | public class StaircasePlot extends ScatterPlot { 11 | 12 | public boolean link = true; 13 | 14 | public StaircasePlot(String n, Color c, boolean[][] _pattern, double[][] _XY) { 15 | super(n, c, _pattern, _XY); 16 | } 17 | 18 | public StaircasePlot(String n, Color c, int _type, int _radius, double[][] _XY) { 19 | super(n, c, _type, _radius, _XY); 20 | } 21 | 22 | public StaircasePlot(String n, Color c, double[][] _XY) { 23 | super(n, c, _XY); 24 | } 25 | 26 | public void plot(AbstractDrawer draw, Color c) { 27 | if (!visible) 28 | return; 29 | 30 | //System.out.println(Array.toString(XY)); 31 | 32 | draw.setColor(c); 33 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 34 | for (int i = 0; i < XY.length - 1; i++) { 35 | double[] begin = XY[i].clone(); 36 | double[] end = XY[i + 1].clone(); 37 | end[end.length - 1] = XY[i][end.length - 1]; 38 | draw.drawLine(begin, end); 39 | } 40 | 41 | //System.out.println(Array.toString(XY)); 42 | 43 | if (link) { 44 | for (int i = 0; i < XY.length - 2; i++) { 45 | double[] begin = XY[i+1].clone(); 46 | double[] end = XY[i + 1].clone(); 47 | begin[begin.length - 1] = XY[i][begin.length - 1]; 48 | draw.drawLine(begin, end); 49 | } 50 | } 51 | //System.out.println(Array.toString(XY)); 52 | 53 | } 54 | 55 | public static void main(String[] args) { 56 | Plot2DPanel p = new Plot2DPanel(); 57 | 58 | double[] X = new double[10]; 59 | double[] Y = new double[10]; 60 | for (int j = 0; j < X.length; j++) { 61 | X[j] = j; 62 | Y[j] = Math.random(); 63 | } 64 | p.addStaircasePlot("toto", X,Y); 65 | 66 | new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/plots/VectorLayerPlot.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.plots; 2 | 3 | import java.awt.*; 4 | 5 | import javax.swing.*; 6 | 7 | import org.math.plot.*; 8 | import org.math.plot.render.*; 9 | import org.math.plot.utils.*; 10 | 11 | /** 12 | * @author Yann RICHET 13 | * @version 1.0 14 | */ 15 | 16 | /**Layer to add a vector field to an existing Plot*/ 17 | public class VectorLayerPlot extends LayerPlot { 18 | 19 | public static int RADIUS = 5; 20 | 21 | double[][] V; 22 | 23 | /**Create a vector fiels based on data of a plot 24 | @param p Base plot to support vector field 25 | @param v Vector field of same lenght that p data */ 26 | public VectorLayerPlot(Plot p, double[][] v) { 27 | super("Vector of " + p.name, p); 28 | if (v != null) { 29 | Array.checkRowDimension(v, p.getData().length); 30 | Array.checkColumnDimension(v, p.getData()[0].length); 31 | } 32 | V = v; 33 | 34 | } 35 | 36 | @Override 37 | public void setData(double[][] v) { 38 | V = v; 39 | } 40 | 41 | @Override 42 | public double[][] getData() { 43 | return V; 44 | } 45 | 46 | public void plot(AbstractDrawer draw, Color c) { 47 | if (!plot.visible) 48 | return; 49 | 50 | draw.setColor(c); 51 | 52 | draw.setLineType(AbstractDrawer.CONTINOUS_LINE); 53 | 54 | for (int i = 0; i < plot.getData().length; i++) { 55 | double[] d = Array.getRowCopy(plot.getData(), i); 56 | for (int j = 0; j < d.length; j++) { 57 | d[j] += V[i][j]; 58 | } 59 | draw.drawLine(plot.getData()[i], d); 60 | //TODO: draw arrow at position d 61 | 62 | } 63 | 64 | } 65 | 66 | public static void main(String[] args) { 67 | Plot2DPanel p2 = new Plot2DPanel(); 68 | double[][] XYZ = new double[100][2]; 69 | double[][] dXYZ = new double[100][2]; 70 | 71 | for (int j = 0; j < XYZ.length; j++) { 72 | XYZ[j][0] = Math.random()*10; 73 | XYZ[j][1] = Math.random()*10; 74 | dXYZ[j][0] = 1.0/Math.sqrt(1+Math.log(XYZ[j][0])*Math.log(XYZ[j][0])); 75 | dXYZ[j][1] = Math.log(XYZ[j][0])/Math.sqrt(1+Math.log(XYZ[j][0])*Math.log(XYZ[j][0])); 76 | } 77 | p2.addScatterPlot("toto", XYZ); 78 | 79 | p2.addVectortoPlot(0, dXYZ); 80 | new FrameView(p2).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 81 | } 82 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/render/AWTDrawer2D.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.render; 2 | 3 | import org.math.plot.canvas.*; 4 | 5 | public class AWTDrawer2D extends AWTDrawer { 6 | 7 | public AWTDrawer2D(PlotCanvas _canvas) { 8 | super(_canvas); 9 | projection = new Projection2D(this); 10 | } 11 | 12 | /*// More efficient method for orthogonal display of images 13 | public void drawImage(Image img,float alpha, double[] _xyzSW, double[] _xyzSE,double[] _xyzNW) { 14 | int[] cornerNW = projection.screenProjection(_xyzNW); 15 | int[] cornerSE = projection.screenProjection(_xyzSE); 16 | int[] cornerSW = projection.screenProjection(_xyzSW); 17 | 18 | AffineTransform transform = new AffineTransform(); 19 | transform.translate(cornerNW[0],cornerNW[1]); 20 | transform.scale((-cornerSW[0]+cornerSE[0])/(double)img.getWidth(canvas),(-cornerNW[1]+cornerSW[1])/(double)img.getHeight(canvas)); 21 | 22 | Composite cs = comp2D.getComposite(); 23 | comp2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,alpha)); 24 | comp2D.drawImage(img, transform,canvas); 25 | comp2D.setComposite(cs); 26 | }*/ 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/render/AWTDrawer3D.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.render; 2 | 3 | import org.math.plot.canvas.*; 4 | 5 | public class AWTDrawer3D extends AWTDrawer { 6 | 7 | public AWTDrawer3D(PlotCanvas _canvas) { 8 | super(_canvas); 9 | projection = new Projection3D(this); 10 | } 11 | 12 | public void rotate(int[] t, int[] panelSize) { 13 | ((Projection3D) projection).rotate(t, panelSize); 14 | } 15 | 16 | public void dilate(int[] screenOrigin, double[] screenRatio) { 17 | super.dilate(screenOrigin, screenRatio); 18 | ((Projection3D) projection).updateCoordsCenterScreen(); 19 | canvas.repaint(); 20 | } 21 | 22 | public void translate(int... t) { 23 | super.translate(t); 24 | ((Projection3D) projection).updateCoordsCenterScreen(); 25 | canvas.repaint(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/render/Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on 31 mai 2005 by richet 3 | */ 4 | package org.math.plot.render; 5 | 6 | import org.math.plot.plotObjects.*; 7 | import org.math.plot.utils.FastMath; 8 | 9 | public abstract class Projection { 10 | 11 | protected int[][] baseScreenCoords; 12 | public static double DEFAULT_BORDER = 0.15; 13 | protected double borderCoeff = 1 - 2 * DEFAULT_BORDER; 14 | protected AWTDrawer draw; 15 | 16 | public Projection(AWTDrawer _draw) { 17 | draw = _draw; 18 | } 19 | 20 | public void initBaseCoordsProjection(boolean reset) { 21 | // System.out.println("Projection.initBaseCoordsProjection"); 22 | if (baseScreenCoords == null) { 23 | baseScreenCoords = new int[draw.canvas.base.baseCoords.length][2]; 24 | } 25 | if (reset) { 26 | totalScreenRatio[0] = 1; 27 | totalScreenRatio[1] = 1; 28 | } 29 | for (int i = 0; i < draw.canvas.base.dimension + 1; i++) { 30 | // Compute the basis extremity coordinates in the normed-centered screen (ie [-0.5,0.5]x[-0.5,0.5] screen) 31 | double[] ratio = new double[]{1,1}; 32 | if (draw.canvas.base.baseCoords!=null) 33 | ratio = baseCoordsScreenProjectionRatio(draw.canvas.base.baseCoords[i]); 34 | // Compute the basis extremity coordinates in the true screen (ie in px: [0,400]x[0,400]) 35 | baseScreenCoords[i][0] = (int) (draw.canvas.getWidth() * (.5 + (borderCoeff * ratio[0] / totalScreenRatio[0]))); 36 | baseScreenCoords[i][1] = (int) (draw.canvas.getHeight() * (.5 - (borderCoeff * ratio[1] / totalScreenRatio[1]))); 37 | } 38 | //System.err.println("\n" + Array.toString(baseScreenCoords)); 39 | } 40 | 41 | // /////////////////////////////////////////// 42 | // ////// move methods /////////////////////// 43 | // /////////////////////////////////////////// 44 | public void translate(int[] screenTranslation) { 45 | for (int i = 0; i < draw.canvas.base.dimension + 1; i++) { 46 | baseScreenCoords[i][0] = baseScreenCoords[i][0] + screenTranslation[0]; 47 | baseScreenCoords[i][1] = baseScreenCoords[i][1] + screenTranslation[1]; 48 | } 49 | } 50 | // This stores the whole zooming ratio along all dilate calls. 51 | public double[] totalScreenRatio = new double[]{1, 1}; 52 | public double[] maxScreenRatio = new double[]{1, 1}; 53 | public double[] minScreenRatio = new double[]{.01, .01}; 54 | 55 | public void dilate(int[] screenOrigin, double[] screenRatio) { 56 | // System.out.println("screenOrigin = "+screenOrigin[0]+" , 57 | // "+screenOrigin[1]); 58 | // System.out.println("screenRatio = "+screenRatio[0]+" , 59 | // "+screenRatio[1]); 60 | 61 | // Update the zooming ratio history 62 | if (totalScreenRatio[0] * screenRatio[0] > maxScreenRatio[0]) screenRatio[0] = maxScreenRatio[0]/totalScreenRatio[0]; 63 | if (totalScreenRatio[1] * screenRatio[1] > maxScreenRatio[1]) screenRatio[1] = maxScreenRatio[1]/totalScreenRatio[1]; 64 | 65 | if (totalScreenRatio[0] * screenRatio[0] < minScreenRatio[0]) screenRatio[0] = minScreenRatio[0]/totalScreenRatio[0]; 66 | if (totalScreenRatio[1] * screenRatio[1] < minScreenRatio[1]) screenRatio[1] = minScreenRatio[1]/totalScreenRatio[1]; 67 | 68 | for (int i = 0; i < draw.canvas.base.dimension + 1; i++) { 69 | // System.out.println("baseScreenCoords["+i+"] = 70 | // "+baseScreenCoords[i][0]+" , "+baseScreenCoords[i][1]); 71 | baseScreenCoords[i][0] = (int) ((baseScreenCoords[i][0] - screenOrigin[0]) / screenRatio[0]); 72 | baseScreenCoords[i][1] = (int) ((baseScreenCoords[i][1] - screenOrigin[1]) / screenRatio[1]); 73 | // System.out.println(" -> baseScreenCoords["+i+"] = 74 | // "+baseScreenCoords[i][0]+" , "+baseScreenCoords[i][1]); 75 | } 76 | // Update the zooming ratio history 77 | totalScreenRatio[0] = totalScreenRatio[0] * screenRatio[0]; 78 | totalScreenRatio[1] = totalScreenRatio[1] * screenRatio[1]; 79 | } 80 | 81 | // /////////////////////////////////////////// 82 | // ////// projection method ////////////////// 83 | // /////////////////////////////////////////// 84 | public int[] screenProjection(double... pC) { 85 | // System.out.println("Projection.screenProjection("+Array.toString(pC)+")"); 86 | double[] sC = new double[2]; 87 | sC[0] = baseScreenCoords[0][0]; 88 | sC[1] = baseScreenCoords[0][1]; 89 | for (int i = 0; i < draw.canvas.base.dimension; i++) { 90 | double normdist_pC_baseCoords = 0; 91 | if (draw.canvas.base.axesScales[i].equalsIgnoreCase(Base.LOGARITHM)) { 92 | normdist_pC_baseCoords = ((FastMath.log(pC[i]) - FastMath.log(draw.canvas.base.baseCoords[0][i])) / (FastMath.log(draw.canvas.base.baseCoords[i + 1][i]) - FastMath.log(draw.canvas.base.baseCoords[0][i]))); 93 | } else if (draw.canvas.base.axesScales[i].equalsIgnoreCase(Base.LINEAR) || draw.canvas.base.axesScales[i].equalsIgnoreCase(Base.STRINGS)) { 94 | if(pC!=null && draw.canvas.base.baseCoords!=null && draw.canvas.base.baseCoords[i+1] != null) 95 | normdist_pC_baseCoords = ((pC[i] - draw.canvas.base.baseCoords[0][i]) / (draw.canvas.base.baseCoords[i + 1][i] - draw.canvas.base.baseCoords[0][i])); 96 | } 97 | sC[0] += normdist_pC_baseCoords * (baseScreenCoords[i + 1][0] - baseScreenCoords[0][0]); 98 | sC[1] += normdist_pC_baseCoords * (baseScreenCoords[i + 1][1] - baseScreenCoords[0][1]); 99 | } 100 | 101 | if (draw.base_offset != null) { 102 | for (int i = 0; i < draw.canvas.base.dimension; i++) { 103 | sC[0] += draw.base_offset[i] * (baseScreenCoords[i + 1][0] - baseScreenCoords[0][0]); 104 | sC[1] += draw.base_offset[i] * (baseScreenCoords[i + 1][1] - baseScreenCoords[0][1]); 105 | } 106 | } 107 | 108 | if (draw.screen_offset != null) { 109 | sC[0] += draw.screen_offset[0]; 110 | sC[1] += draw.screen_offset[1]; 111 | } 112 | 113 | return new int[]{(int) sC[0], (int) sC[1]}; 114 | } 115 | 116 | public int[] screenProjectionBase(double... rC) { 117 | double[] sC = new double[2]; 118 | sC[0] = baseScreenCoords[0][0]; 119 | sC[1] = baseScreenCoords[0][1]; 120 | for (int i = 0; i < draw.canvas.base.dimension; i++) { 121 | sC[0] += rC[i] * (baseScreenCoords[i + 1][0] - baseScreenCoords[0][0]); 122 | sC[1] += rC[i] * (baseScreenCoords[i + 1][1] - baseScreenCoords[0][1]); 123 | } 124 | 125 | if (draw.base_offset != null) { 126 | for (int i = 0; i < draw.canvas.base.dimension; i++) { 127 | sC[0] += draw.base_offset[i] * (baseScreenCoords[i + 1][0] - baseScreenCoords[0][0]); 128 | sC[1] += draw.base_offset[i] * (baseScreenCoords[i + 1][1] - baseScreenCoords[0][1]); 129 | } 130 | } 131 | 132 | if (draw.screen_offset != null) { 133 | sC[0] += draw.screen_offset[0]; 134 | sC[1] += draw.screen_offset[1]; 135 | } 136 | 137 | return new int[]{(int) sC[0], (int) sC[1]}; 138 | } 139 | 140 | protected abstract double[] baseCoordsScreenProjectionRatio(double[] xyz); 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/org/math/plot/render/Projection2D.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.render; 2 | 3 | /** 4 | * BSD License 5 | * 6 | * @author Yann RICHET 7 | */ 8 | public class Projection2D extends Projection { 9 | 10 | public Projection2D(AWTDrawer _draw) { 11 | super(_draw); 12 | initBaseCoordsProjection(true); 13 | } 14 | 15 | protected double[] baseCoordsScreenProjectionRatio(double[] xy) { 16 | double[] sC = new double[2]; 17 | sC[0] = -0.5+(xy[0] - draw.canvas.base.roundXmin[0]) / (draw.canvas.base.roundXmax[0] - draw.canvas.base.roundXmin[0]); 18 | sC[1] = -0.5+(xy[1] - draw.canvas.base.roundXmin[1]) / (draw.canvas.base.roundXmax[1] - draw.canvas.base.roundXmin[1]); 19 | // System.out.println("(" + xy[0] +"," + xy[1] + ") -> (" + sC[0] + "," 20 | // + sC[1] + ")"); 21 | return sC; 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/render/Projection3D.java: -------------------------------------------------------------------------------- 1 | package org.math.plot.render; 2 | 3 | import org.math.plot.utils.FastMath; 4 | 5 | /** 6 | * BSD License 7 | * 8 | * @author Yann RICHET 9 | */ 10 | public class Projection3D extends Projection { 11 | 12 | public double theta; 13 | public double phi; 14 | 15 | // protected boolean useRoundTrigonometry = false; 16 | public Projection3D(AWTDrawer _draw) { 17 | super(_draw); 18 | theta(Math.PI / 4); 19 | phi(Math.PI / 4); 20 | initBaseCoordsProjection(true); 21 | } 22 | public double factor = 1.4; 23 | public double x0, y0, z0; 24 | public double cos_phi, sin_phi, tan_phi, cos_theta, sin_theta, tan_theta; 25 | static double pi = Math.PI; 26 | 27 | private void theta(double theta) { 28 | if (theta == this.theta) { 29 | //System.err.println("o"); 30 | return; 31 | } 32 | this.theta = theta; 33 | cos_theta = cos(theta); 34 | sin_theta = sin(theta); 35 | tan_theta = tan(theta); 36 | } 37 | 38 | private void phi(double phi) { 39 | if (phi == this.phi) { 40 | //System.err.println("."); 41 | return; 42 | } 43 | this.phi = phi; 44 | cos_phi = cos(phi); 45 | sin_phi = sin(phi); 46 | tan_phi = tan(phi); 47 | } 48 | 49 | public void initBaseCoordsProjection(boolean reset) { 50 | if (reset) { 51 | x0 = (draw.canvas.base.roundXmax[0] + draw.canvas.base.roundXmin[0]) / 2; 52 | y0 = (draw.canvas.base.roundXmax[1] + draw.canvas.base.roundXmin[1]) / 2; 53 | z0 = (draw.canvas.base.roundXmax[2] + draw.canvas.base.roundXmin[2]) / 2; 54 | } 55 | super.initBaseCoordsProjection(reset); 56 | } 57 | // search for (x0,y0,z0) , matching center of the screen [.5,.5] and closest to the center (.5,.5,.5) of the plot 58 | 59 | protected void updateCoordsCenterScreen() { 60 | double dx0 = (draw.canvas.getWidth() * .5 - baseScreenCoords[0][0]) / (baseScreenCoords[1][0] - baseScreenCoords[0][0]); 61 | double dy0 = (draw.canvas.getWidth() * .5 - baseScreenCoords[0][0]) / (baseScreenCoords[2][0] - baseScreenCoords[0][0]); 62 | 63 | double dz0 = (draw.canvas.getHeight() * .5 - baseScreenCoords[0][1]) / (baseScreenCoords[3][1] - baseScreenCoords[0][1]); 64 | double dx, dy, dz = 0; 65 | if ((theta - pi / 4) % pi > pi / 2) { 66 | dx = (.5 * (sin_theta + cos_theta) - tan_theta * dy0) / (sin_theta * sin_theta + cos_theta); 67 | dy = tan_theta * dx + dy0; 68 | } else { 69 | dy = (.5 * (sin_theta + cos_theta) - cos_theta * dx0) / (cos_theta / tan_theta + sin_theta); 70 | dx = 1 / tan_theta * dy + dx0; 71 | } 72 | dz = dz0 + .5 * tan_phi; 73 | 74 | // uuuhhh :) I've always dreamed to speak perl... 75 | dx = (dx < 0 ? 0 : (dx > 1 ? 1 : dx)); 76 | dy = (dy < 0 ? 0 : (dy > 1 ? 1 : dy)); 77 | dz = (dz < 0 ? 0 : (dz > 1 ? 1 : dz)); 78 | 79 | x0 = draw.canvas.base.roundXmin[0] + (draw.canvas.base.roundXmax[0] - draw.canvas.base.roundXmin[0]) * dx; 80 | y0 = draw.canvas.base.roundXmin[1] + (draw.canvas.base.roundXmax[1] - draw.canvas.base.roundXmin[1]) * dy; 81 | z0 = draw.canvas.base.roundXmin[2] + (draw.canvas.base.roundXmax[2] - draw.canvas.base.roundXmin[2]) * dz; 82 | //System.err.println("(x0,y0,z0) = " + x0 + " " + y0 + " " + z0); 83 | } 84 | 85 | protected double[] baseCoordsScreenProjectionRatio(double[] xyz) { 86 | double normdist_xyz_x0 = ((xyz[0] - x0) / (draw.canvas.base.roundXmax[0] - draw.canvas.base.roundXmin[0])); 87 | double normdist_xyz_y0 = ((xyz[1] - y0) / (draw.canvas.base.roundXmax[1] - draw.canvas.base.roundXmin[1])); 88 | double normdist_xyz_z0 = ((xyz[2] - z0) / (draw.canvas.base.roundXmax[2] - draw.canvas.base.roundXmin[2])); 89 | 90 | double[] sC = new double[2]; 91 | sC[0] = (cos_theta * normdist_xyz_y0 92 | - sin_theta * normdist_xyz_x0) 93 | / factor; 94 | sC[1] = (cos_phi * normdist_xyz_z0 95 | - sin_phi * cos_theta * normdist_xyz_x0 96 | - sin_phi * sin_theta * normdist_xyz_y0) 97 | / factor; 98 | //System.out.println("Theta = " + theta + " Phi = " + phi); 99 | // System.err.println("(" + xyz[0] +"," + xyz[1] +"," + xyz[2] + ") -> (" + sC[0] + "," + sC[1] + ")"); 100 | return sC; 101 | } 102 | 103 | // TODO test efficiceny of an approximation of cos and sin fuctions. 104 | /* 105 | * private final static double _2PI = 2 * Math.PI; 106 | * 107 | * private final static int N = 100; 108 | * 109 | * private final static double[] COS = 110 | * DoubleArray.f(DoubleArray.increment(N, 0, 2 * Math.PI / (N - 1)), new 111 | * Function() { public double f(double x) { return Math.cos(x); } }); 112 | * 113 | * private final static double[] SIN = 114 | * DoubleArray.f(DoubleArray.increment(N, 0, 2 * Math.PI / (N - 1)), new 115 | * Function() { public double f(double x) { return Math.sin(x); } }); 116 | */ 117 | private double cos(double x) { 118 | return FastMath.cos(x); 119 | } 120 | 121 | private double tan(double x) { 122 | return FastMath.tan(x); 123 | } 124 | 125 | private double sin(double x) { 126 | return FastMath.sin(x); 127 | } 128 | 129 | public void rotate(double _theta, double _phi) { 130 | theta(_theta); 131 | phi(_phi); 132 | initBaseCoordsProjection(false); 133 | } 134 | 135 | public void rotate(int[] screenTranslation, int[] dimension) { 136 | theta(theta - ((double) screenTranslation[0]) / 100); 137 | phi(phi + ((double) screenTranslation[1]) / 100); 138 | initBaseCoordsProjection(false); 139 | } 140 | } -------------------------------------------------------------------------------- /src/main/java/org/math/plot/utils/Histogram.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on 21 juil. 2005 by richet 3 | */ 4 | package org.math.plot.utils; 5 | 6 | import static org.math.plot.utils.Array.*; 7 | 8 | public class Histogram { 9 | // histograms functions 10 | 11 | public static double[][] histogram_classes(double[] values, double[] bounds) { 12 | return mergeColumns(centers(bounds), histogram(values, bounds)); 13 | } 14 | 15 | public static double[][] histogram_classes(double[] values, double min, double max, int n) { 16 | double[] bounds = bounds(values, min, max, n); 17 | return mergeColumns(centers(bounds), histogram(values, bounds)); 18 | } 19 | 20 | public static double[][] histogram_classes(double[] values, int n) { 21 | double[] bounds = bounds(values, n); 22 | return mergeColumns(centers(bounds), histogram(values, bounds)); 23 | } 24 | 25 | public static double[] histogram(double[] values, double[] bounds) { 26 | double[] h = new double[bounds.length - 1]; 27 | for (int i = 0; i < values.length; i++) { 28 | for (int j = 0; j < h.length; j++) { 29 | if (((bounds[j + 1] - values[i]) * (bounds[j] - values[i]) <= 0) || ((bounds[j] == values[i]))) { 30 | h[j]++; 31 | break; 32 | } 33 | } 34 | } 35 | return h; 36 | } 37 | 38 | public static double[] histogram(double[] values, double min, double max, int n) { 39 | double[] bounds = bounds(values, min, max, n); 40 | return histogram(values, bounds); 41 | } 42 | 43 | public static double[] histogram(double[] values, int n) { 44 | return histogram(values, n); 45 | } 46 | 47 | private static double[] bounds(double[] values, int n) { 48 | double min = min(values); 49 | double max = max(values); 50 | return bounds(values, min, max, n); 51 | } 52 | 53 | private static double[] bounds(double[] values, double min, double max, int n) { 54 | double[] bounds = new double[n + 1]; 55 | for (int i = 0; i < bounds.length; i++) { 56 | bounds[i] = min + (max - min) * i / (double) n; 57 | } 58 | return bounds; 59 | } 60 | 61 | private static double[] centers(double[] bounds) { 62 | double[] center = new double[bounds.length - 1]; 63 | for (int i = 0; i < center.length; i++) 64 | center[i] = (bounds[i] + bounds[i + 1]) / 2; 65 | return center; 66 | } 67 | 68 | // histograms 2D functions 69 | 70 | public static double[][] histogram_classes_2D(double[][] values, double[] boundsX, double[] boundsY) { 71 | return insertColumn(centers_2D(boundsX, boundsY), histogram_2D(values, boundsX, boundsY), 2); 72 | } 73 | 74 | public static double[][] histogram_classes_2D(double[][] values, double minX, double maxX, int nX, double minY, double maxY, int nY) { 75 | double[] valuesX = getColumnCopy(values, 0); 76 | double[] valuesY = getColumnCopy(values, 1); 77 | double[] boundsX = bounds(valuesX, minX, maxX, nX); 78 | double[] boundsY = bounds(valuesY, minY, maxY, nY); 79 | return insertColumn(centers_2D(boundsX, boundsY), histogram_2D(values, boundsX, boundsY), 2); 80 | } 81 | 82 | public static double[][] histogram_classes_2D(double[][] values, int nX, int nY) { 83 | double[] valuesX = getColumnCopy(values, 0); 84 | double[] valuesY = getColumnCopy(values, 1); 85 | double[] boundsX = bounds(valuesX, nX); 86 | double[] boundsY = bounds(valuesY, nY); 87 | return insertColumn(centers_2D(boundsX, boundsY), histogram_2D(values, boundsX, boundsY), 2); 88 | } 89 | 90 | public static double[] histogram_2D(double[][] values, double[] boundsX, double[] boundsY) { 91 | double[] h = new double[(boundsX.length - 1) * (boundsY.length - 1)]; 92 | for (int n = 0; n < values.length; n++) { 93 | for (int i = 0; i < boundsX.length - 1; i++) { 94 | for (int j = 0; j < boundsY.length - 1; j++) { 95 | if ((((boundsX[i + 1] - values[n][0]) * (boundsX[i] - values[n][0]) < 0) || ((boundsX[i] == values[n][0]))) 96 | && (((boundsY[j + 1] - values[n][1]) * (boundsY[j] - values[n][1]) < 0) || ((boundsY[j] == values[n][1])))) 97 | h[index2(i, j, boundsX.length - 1)]++; 98 | } 99 | } 100 | } 101 | return h; 102 | } 103 | 104 | public static double[] histogram_2D(double[][] values, double minX, double maxX, int nX, double minY, double maxY, int nY) { 105 | double[] valuesX = getColumnCopy(values, 0); 106 | double[] valuesY = getColumnCopy(values, 1); 107 | double[] boundsX = bounds(valuesX, minX, maxX, nX); 108 | double[] boundsY = bounds(valuesY, minY, maxY, nY); 109 | return histogram_2D(values, boundsX, boundsY); 110 | } 111 | 112 | public static double[] histogram_2D(double[][] values, int nX, int nY) { 113 | double[] valuesX = getColumnCopy(values, 0); 114 | double[] valuesY = getColumnCopy(values, 1); 115 | double[] boundsX = bounds(valuesX, nX); 116 | double[] boundsY = bounds(valuesY, nY); 117 | return histogram_2D(values, boundsX, boundsY); 118 | } 119 | 120 | private static double[][] centers_2D(double[] boundsX, double[] boundsY) { 121 | int nb_centers = (boundsX.length - 1) * (boundsY.length - 1); 122 | double[][] center = new double[nb_centers][2]; 123 | for (int i = 0; i < boundsX.length - 1; i++) { 124 | for (int j = 0; j < boundsY.length - 1; j++) { 125 | int k = index2(i, j, boundsX.length - 1); 126 | center[k][0] = (boundsX[i] + boundsX[i + 1]) / 2; 127 | center[k][1] = (boundsY[j] + boundsY[j + 1]) / 2; 128 | } 129 | } 130 | return center; 131 | } 132 | 133 | private static int index2(int i, int j, int imax) { 134 | return i + imax * j; 135 | } 136 | 137 | // histograms 3D functions 138 | 139 | 140 | 141 | 142 | public static double[][] histogram_classes_3D(double[][] values, int nX, int nY, int nZ) { 143 | double[] valuesX = getColumnCopy(values, 0); 144 | double[] valuesY = getColumnCopy(values, 1); 145 | double[] valuesZ = getColumnCopy(values, 2); 146 | double[] boundsX = bounds(valuesX, nX); 147 | double[] boundsY = bounds(valuesY, nY); 148 | double[] boundsZ = bounds(valuesZ, nZ); 149 | return insertColumn(centers_3D(boundsX, boundsY, boundsZ), histogram_3D(values, boundsX, boundsY, boundsZ), 3); 150 | } 151 | 152 | public static double[] histogram_3D(double[][] values, double[] boundsX, double[] boundsY, double[] boundsZ) { 153 | double[] h = new double[(boundsX.length - 1) * (boundsY.length - 1)* (boundsZ.length - 1)]; 154 | for (int n = 0; n < values.length; n++) { 155 | for (int i = 0; i < boundsX.length - 1; i++) { 156 | for (int j = 0; j < boundsY.length - 1; j++) { 157 | for (int k = 0; k < boundsZ.length - 1; k++) { 158 | if ((((boundsX[i + 1] - values[n][0]) * (boundsX[i] - values[n][0]) < 0) || ((boundsX[i] == values[n][0]))) 159 | && (((boundsY[j + 1] - values[n][1]) * (boundsY[j] - values[n][1]) < 0) || ((boundsY[j] == values[n][1])))&& (((boundsZ[k + 1] - values[n][2]) * (boundsZ[k] - values[n][2]) < 0) || ((boundsZ[k] == values[n][2])))) 160 | h[index3(i, j,k, boundsX.length - 1, boundsY.length - 1)]++; 161 | }} 162 | } 163 | } 164 | return h; 165 | } 166 | 167 | 168 | 169 | private static double[][] centers_3D(double[] boundsX, double[] boundsY, double[] boundsZ) { 170 | int nb_centers = (boundsX.length - 1) * (boundsY.length - 1)* (boundsZ.length - 1); 171 | double[][] center = new double[nb_centers][3]; 172 | for (int i = 0; i < boundsX.length - 1; i++) { 173 | for (int j = 0; j < boundsY.length - 1; j++) { 174 | for (int k = 0; k < boundsZ.length - 1; k++) { 175 | int l = index3(i, j,k, boundsX.length - 1, boundsY.length - 1); 176 | center[l][0] = (boundsX[i] + boundsX[i + 1]) / 2; 177 | center[l][1] = (boundsY[j] + boundsY[j + 1]) / 2; 178 | center[l][2] = (boundsZ[k] + boundsZ[k + 1]) / 2; 179 | } 180 | } 181 | } 182 | return center; 183 | } 184 | 185 | 186 | 187 | 188 | private static int index3(int i, int j, int k,int imax, int jmax) { 189 | return i + imax * j + imax*jmax*k; 190 | } 191 | 192 | } 193 | -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/adjustbounds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/adjustbounds.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/back.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/center.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/data.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/edit.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/noadjustbounds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/noadjustbounds.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/position.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/position.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/rotation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/rotation.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/scale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/scale.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/toclipboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/toclipboard.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/tofile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/tofile.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/topngfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/topngfile.png -------------------------------------------------------------------------------- /src/main/resources/org/math/plot/icons/zoom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yannrichet/jmathplot/2938687e601c7f6782e8200ea991c6f160c13917/src/main/resources/org/math/plot/icons/zoom.png -------------------------------------------------------------------------------- /src/test/resources/TestApplet.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

7 | 8 | 9 |

10 | 11 | --------------------------------------------------------------------------------