Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main/java/org/jlab/groot/ui/DescriptorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,12 @@ public void actionPerformed(ActionEvent e) {
String xerr = branchVariableFieldXerr.getText();
String y = branchVariableFieldY.getText();
String yerr = branchVariableFieldYerr.getText();
if ((xerr == "" || xerr == "0") && (yerr == "" || yerr == "0")) {
descriptor = new DatasetDescriptor(descriptorName.getText(), x + ":" + y, tree);
} else if ((xerr == "" || xerr == "0")) {
if (xerr == "" || xerr == "0") {
if (yerr == "" || yerr == "0"){
descriptor = new DatasetDescriptor(descriptorName.getText(), x + ":" + y, tree);
}
}
} if ((xerr == "" || xerr == "0")) {
descriptor = new DatasetDescriptor(descriptorName.getText(), x + ":" + y + ":" + yerr, tree);
} else {
descriptor = new DatasetDescriptor(descriptorName.getText(),
Expand Down
60 changes: 41 additions & 19 deletions src/main/java/org/jlab/groot/ui/FitPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,15 @@ private double getMeanIDataSet(IDataSet data, double min, double max) {
for (int i = 0; i < data.getDataSize(0); i++) {
double x = data.getDataX(i);
double y = data.getDataY(i);
if (x > min && x < max && y != 0) {
nsamples++;
sum += x * y;
nEntries += y;
if (x > min) {
if (x < max){

}
if (y != 0){
nsamples++;
sum += x * y;
nEntries += y;
}
}
}
return sum / (double) nEntries;
Expand All @@ -455,10 +460,15 @@ private double getRMSIDataSet(IDataSet data, double min, double max) {
for (int i = 0; i < data.getDataSize(0); i++) {
double x = data.getDataX(i);
double y = data.getDataY(i);
if (x > min && x < max && y != 0) {
nsamples++;
sum += Math.pow(x - mean, 2) * y;
nEntries += y;
if (x > min && x < max) {
if (x < max){

}
if (y != 0){
nsamples++;
sum += Math.pow(x - mean, 2) * y;
nEntries += y;
}
}
}
return Math.sqrt(sum / (double) nEntries);
Expand All @@ -470,9 +480,13 @@ private double getAverageHeightIDataSet(IDataSet data, double min, double max) {
for (int i = 0; i < data.getDataSize(0); i++) {
double x = data.getDataX(i);
double y = data.getDataY(i);
if (x > min && x < max && y != 0) {
nsamples++;
sum += y;
if (x > min) {
if (x < max){
if (y != 0){
nsamples++;
sum += y;
}
}
}
}
return sum / (double) nsamples;
Expand All @@ -484,10 +498,14 @@ private double getMaxXIDataSet(IDataSet data, double min, double max) {
for (int i = 0; i < data.getDataSize(0); i++) {
double x = data.getDataX(i);
double y = data.getDataY(i);
if (x > min && x < max && y != 0) {
if (y > max1) {
max1 = y;
xMax = x;
if (x > min) {
if (x < max){
if (y != 0){
if (y > max1) {
max1 = y;
xMax = x;
}
}
}
}
}
Expand All @@ -499,10 +517,14 @@ private double getMaxYIDataSet(IDataSet data, double min, double max) {
for (int i = 0; i < data.getDataSize(0); i++) {
double x = data.getDataX(i);
double y = data.getDataY(i);
if (x > min && x < max && y != 0) {
if (y > max1) {
max1 = y;
xMax = x;
if (x > min) {
if (x < max){
if (y != 0){
if (y > max1) {
max1 = y;
xMax = x;
}
}
}
}
}
Expand Down
68 changes: 38 additions & 30 deletions src/main/java/org/jlab/groot/ui/GraphicsAxisFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ public double getPointX(double value){

public double getPointY(double value){
double frac = graphicsAxis.get(1).getRange().getFraction(value);
/*int xticks_y = (int) (this.frameDimensions.getDimension(1).getMax()
graphicsAxis.get(1).getDimension().getMin());
*/
int xticks_y = (int) (frameDimensions.getDimension(1).getMax() -
(graphicsAxis.get(1).getDimension().getMin() - frameDimensions.getDimension(1).getMin()));
int max = frameDimensions.getDimension(1).getMax();
int min = graphicsAxis.get(1).getDimension().getMin() - frameDimensions.getDimension(1).getMin();
int xticks_y = (int) ( max - min);
double length = graphicsAxis.get(1).getDimension().getLength();
/*System.out.println(" X = " + xticks_y + " data = " + value +
" fraction = " + frac + " length = " + length);
Expand Down Expand Up @@ -169,15 +167,17 @@ public void draw(Graphics2D g2d, Dimension2D frame){
/*int xticks_y = (int) (frame.getDimension(1).getLength()-
graphicsAxis.get(1).getDimension().getMin());
*/
int xticks_y = (int) (frameDimensions.getDimension(1).getMax() -
(graphicsAxis.get(1).getDimension().getMin() - frameDimensions.getDimension(1).getMin()));
int max = frameDimensions.getDimension(1).getMax();
int min = graphicsAxis.get(1).getDimension().getMin() - frameDimensions.getDimension(1).getMin();
int xticks_y = (int) (max - min);
//System.out.println(" Y AXIS = " + graphicsAxis.get(1).getDimension());
//System.out.println("DRAING AXIS X at Y = " + xticks_y);

int max1 = graphicsAxis.get(0).getDimension().getMin();
int min1 = graphicsAxis.get(0).getDimension().getMax();
g2d.drawLine(
(int) graphicsAxis.get(0).getDimension().getMin(),
(int) max1 ,
xticks_y,
(int) graphicsAxis.get(0).getDimension().getMax(),
(int) min1,
xticks_y
);
List<Double> xTicks = graphicsAxis.get(0).getAxisTicks();
Expand Down Expand Up @@ -208,11 +208,12 @@ public void draw(Graphics2D g2d, Dimension2D frame){
* Draw the Y-axis
*/
int yticks_x = (int) graphicsAxis.get(0).getDimension().getMin();

int max2 = frame.getDimension(1).getLength() - graphicsAxis.get(1).getDimension().getMin();
int min2 = frame.getDimension(1).getLength() - graphicsAxis.get(1).getDimension().getMax();
g2d.drawLine( yticks_x,
(int) (frame.getDimension(1).getLength() - graphicsAxis.get(1).getDimension().getMin()),
(int) max2,
yticks_x,
(int) (frame.getDimension(1).getLength() - graphicsAxis.get(1).getDimension().getMax())
(int) min2
);

List<Double> yTicks = graphicsAxis.get(1).getAxisTicks();
Expand All @@ -236,11 +237,13 @@ public void draw(Graphics2D g2d, Dimension2D frame){
g2d.drawLine(yticks_x,ytick, yticks_x+ (int) (0.5*tickSize),ytick);
}
if(this.frameAttributes.get(AttributeType.AXIS_FRAME_STYLE)>0){

int length = this.graphicsAxis.get(1).getDimension().getLength();
int l0 = this.graphicsAxis.get(0).getDimension().getLength();
int l1 = this.graphicsAxis.get(1).getDimension().getLength();
g2d.drawRect(yticks_x,
(int) ( xticks_y-this.graphicsAxis.get(1).getDimension().getLength()),
(int) this.graphicsAxis.get(0).getDimension().getLength(),
(int) this.graphicsAxis.get(1).getDimension().getLength()
(int) ( xticks_y-length),
(int) l0,
(int) l1
);
}
/**
Expand All @@ -260,13 +263,16 @@ public void draw(Graphics2D g2d, Dimension2D frame){
}

public void update(Graphics2D g2d){

int max0 = this.frameDimensions.getDimension(0).getMin();
int min0 = this.frameDimensions.getDimension(0).getMax();
int max1 = this.frameDimensions.getDimension(1).getMin();
int min1 = this.frameDimensions.getDimension(1).getMax();
this.graphicsAxis.get(0).setDimension(
(int) this.frameDimensions.getDimension(0).getMin(),
(int) this.frameDimensions.getDimension(0).getMax());
(int) max0,
(int) min0);
this.graphicsAxis.get(1).setDimension(
(int) this.frameDimensions.getDimension(1).getMin(),
(int) this.frameDimensions.getDimension(1).getMax()
(int) max1,
(int) min1
);

this.graphicsAxis.get(0).setAxisDivisions(10);
Expand Down Expand Up @@ -303,19 +309,21 @@ public void update(Graphics2D g2d){


if(this.frameAttributes.get(AttributeType.AXIS_DRAW_Z)>0){
int zAxisWidth = zAxisPalette.getAxisWidth(g2d, 0, 0, 15,
(int) this.frameDimensions.getDimension(1).getLength()
, 0.0,400.0,this.getAxis(2).getLog());
boolean log = this.getAxis(2).getLog();
double leng = this.frameDimensions.getDimension(1).getLength();
int zAxisWidth = zAxisPalette.getAxisWidth(g2d, 0, 0, 15, (int) leng, 0.0,400.0,log);
//System.out.println(" MARGINS RIGHT moved by " + zAxisWidth);
this.axisFrameMargins.setRightMargin(15+zAxisWidth);
}

int marginBottom =frameDimensions.getDimension(1).getMin()+axisFrameMargins.getBottomMargin();
int marginTop = frameDimensions.getDimension(1).getMax()-axisFrameMargins.getTopMargin();
int marginLeft = frameDimensions.getDimension(0).getMin()+axisFrameMargins.getLeftMargin();
int marginRight = frameDimensions.getDimension(0).getMax()-axisFrameMargins.getRightMargin();
this.graphicsAxis.get(1).setDimension(
(int) frameDimensions.getDimension(1).getMin()+axisFrameMargins.getBottomMargin(),
(int) frameDimensions.getDimension(1).getMax()-axisFrameMargins.getTopMargin() );
marginBottom, marginTop);
this.graphicsAxis.get(0).setDimension(
(int) frameDimensions.getDimension(0).getMin()+axisFrameMargins.getLeftMargin(),
(int) frameDimensions.getDimension(0).getMax()-axisFrameMargins.getRightMargin()
marginLeft, marginRight

);

}
Expand Down
20 changes: 15 additions & 5 deletions src/main/java/org/jlab/groot/ui/OptionsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,21 @@ public void keyTyped(KeyEvent e) {
gridPanel.add(yGridBox);

JPanel applyToAllPanel = new JPanel(new BorderLayout());
String[] applyToAllOptions = {"Font","Title Font Size","Axis Title Font Size","Axis Label Font Size","Stat Box Font Size","Title","X Axis Title","Y Axis Title","Grid X","Grid Y"};
List<String> aplly = new ArrayList<String>();
aplly.add("Font");
aplly.add("Title Font Size");
aplly.add("Axis Title Font Size");
aplly.add("Axis Label Font Size");
aplly.add("Stat Box Font Size");
aplly.add("Title");
aplly.add("X Axis Title");
aplly.add("Y Axis Title");
aplly.add("Grid X");
aplly.add("Grid Y");
boolean[] applyToAllDefaults = {true,true,true,true,true,false,false,false,true,true,false,false};
applyToAllCheckBoxes = new JCheckBox[applyToAllOptions.length];
for(int i=0; i<applyToAllOptions.length; i++){
applyToAllCheckBoxes[i] = new JCheckBox(applyToAllOptions[i]);
applyToAllCheckBoxes = new JCheckBox[aplly.size()];
for(int i=0; i<aplly.size(); i++){
applyToAllCheckBoxes[i] = new JCheckBox(aplly.get(i));
applyToAllCheckBoxes[i].setSelected(applyToAllDefaults[i]);
}
JComboCheckBox applyToAllComboCheckBox = new JComboCheckBox(applyToAllCheckBoxes);
Expand Down Expand Up @@ -208,7 +218,7 @@ public void itemStateChanged(ItemEvent e) {
}

};
for(int i=0; i<applyToAllOptions.length; i++){
for(int i=0; i<aplly.size(); i++){
applyToAllCheckBoxes[i].addItemListener(itemListener);
}
applyToAllComboCheckBox.addActionListener(applyToAllListener);
Expand Down
25 changes: 21 additions & 4 deletions src/main/java/org/jlab/groot/ui/ParameterPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ public void actionPerformed(ActionEvent e){
double xHigh = Double.parseDouble(parameterMax.get(i).getText());
double sliderMax = parameterValueSliders.get(i).getMaximum();
double sliderMin = parameterValueSliders.get(i).getMinimum();
parameterValueSliders.get(i).setValue((int)((fitFunction.parameter(i).value()-xLow)/((xHigh-xLow)/(double)(sliderMax-sliderMin))));
double topTemp = (fitFunction.parameter(i).value()-xLow);
double downTemp = (xHigh-xLow);
double downFinal = (double)(sliderMax-sliderMin);
downFinal = (downTemp/downFinal);
int result = (int)(topTemp/downFinal);
parameterValueSliders.get(i).setValue(result);
}
}
}
Expand All @@ -112,7 +117,12 @@ public void actionPerformed(ActionEvent e){
double xHigh = Double.parseDouble(parameterMax.get(i).getText());
double sliderMax = parameterValueSliders.get(i).getMaximum();
double sliderMin = parameterValueSliders.get(i).getMinimum();
parameterValueSliders.get(i).setValue((int)((fitFunction.parameter(i).value()-xLow)/((xHigh-xLow)/(double)(sliderMax-sliderMin))));
double topTemp = (fitFunction.parameter(i).value()-xLow);
double downTemp = (xHigh-xLow);
double downFinal = (double)(sliderMax-sliderMin);
downFinal = (downTemp/downFinal);
int result = (int)(topTemp/downFinal);
parameterValueSliders.get(i).setValue(result);
}
}
}
Expand All @@ -125,8 +135,15 @@ public void actionPerformed(ActionEvent e){
double xHigh = Double.parseDouble(parameterMax.get(i).getText());
double sliderMax = parameterValueSliders.get(i).getMaximum();
double sliderMin = parameterValueSliders.get(i).getMinimum();
parameterValueSliders.get(i).setValue((int)((fitFunction.parameter(i).value()-xLow)/((xHigh-xLow)/(double)(sliderMax-sliderMin))));
System.out.println("Initialize Slider:"+(int)((fitFunction.parameter(i).value()- xLow)/((xHigh-xLow)/(double)(sliderMax-sliderMin) )));
int top = (int)((fitFunction.parameter(i).value()-xLow)/((xHigh-xLow)));
double down = (double)(sliderMax-sliderMin);
parameterValueSliders.get(i).setValue((int)(top/down));
double topD =(fitFunction.parameter(i).value()- xLow);
double down1 = (xHigh-xLow);
double down2 = (double)(sliderMax-sliderMin);
double resultTemp = down/down2;
int resultRight = (int)(topD/resultTemp);
System.out.println("Initialize Slider:"+ resultRight);
parameterValueLabel.add(new JLabel("Value:"));
parameterName.add(new JLabel());
parameterName.get(i).setText(fitFunction.parameter(i).name());
Expand Down
37 changes: 15 additions & 22 deletions src/main/java/org/jlab/groot/ui/PaveText.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
*/
package org.jlab.groot.ui;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.text.CharacterIterator;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -79,20 +76,14 @@ public void drawPave(Graphics2D g2d, int x , int y){

this.updateDimensions(g2d);
g2d.setColor(this.backgroundColor);
g2d.fillRect(
(int) this.paveDimension.getDimension(0).getMin() - xPadding,
(int) this.paveDimension.getDimension(1).getMin() - yPadding,
(int) this.paveDimension.getDimension(0).getLength() + 2*xPadding,
(int) this.paveDimension.getDimension(1).getLength() + 2*yPadding
);
int xx = (int) this.paveDimension.getDimension(0).getMin() - xPadding;
int yy = (int) this.paveDimension.getDimension(1).getMin() - yPadding;
int widthXX = (int) this.paveDimension.getDimension(0).getLength() + 2*xPadding;
int heightXX = (int) this.paveDimension.getDimension(1).getLength() + 2*yPadding;
g2d.fillRect( xx, yy, widthXX, heightXX);

g2d.setColor(Color.BLACK);
g2d.drawRect(
(int) this.paveDimension.getDimension(0).getMin() - xPadding,
(int) this.paveDimension.getDimension(1).getMin() - yPadding,
(int) this.paveDimension.getDimension(0).getLength() + 2*xPadding,
(int) this.paveDimension.getDimension(1).getLength() + 2*yPadding
);
g2d.drawRect(xx, yy, widthXX, heightXX);
/*g2d.drawRoundRect(
(int) this.paveDimension.getDimension(0).getMin() - xPadding,
(int) this.paveDimension.getDimension(1).getMin() - yPadding,
Expand Down Expand Up @@ -140,8 +131,9 @@ public void updateDimensions(Graphics2D g2d){
double height = 0;
for(List<LatexText> list : this.paveTexts){
for(int i = 0; i < this.N_COLUMNS; i++){
Rectangle2D rect = fmg.getStringBounds(list.get(i).getText().getIterator(), 0,
list.get(i).getText().getIterator().getEndIndex(),g2d);
int limit = list.get(i).getText().getIterator().getEndIndex();
CharacterIterator ci = list.get(i).getText().getIterator();
Rectangle2D rect = fmg.getStringBounds(ci, 0, limit,g2d);
if(rect.getWidth()>widths[i]) widths[i] = rect.getWidth();
height += rect.getHeight()/this.N_COLUMNS;
}
Expand All @@ -150,10 +142,11 @@ public void updateDimensions(Graphics2D g2d){
double width = 0.0;
for(int i = 0; i < widths.length; i++) width+= widths[i];
ySpacing = (int) (1.1*height/this.paveTexts.size());

double min = (int) paveDimension.getDimension(0).getMin();
in max = this.xLeftOffset + paveDimension.getDimension(0).getMin() + width + xSpacing;
this.paveDimension.getDimension(0).setMinMax(
paveDimension.getDimension(0).getMin(),
this.xLeftOffset + paveDimension.getDimension(0).getMin() + width + xSpacing
min,
max
);
this.paveDimension.getDimension(1).setMinMax(
paveDimension.getDimension(1).getMin(),
Expand Down