Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes applied #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions src/main/java/org/jlab/groot/data/DataLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*
* @author gavalian
*/
public class DataLine {
public class DataLine extends SetEndandOrigin{

private double originX = 0.0;
private double originY = 0.0;
private double endX = 0.0;
Expand All @@ -21,19 +21,19 @@ public class DataLine {
private int lineWidth = 2;
private int lineStyle = 1;
private double arrowAngle = 30.0;

SetEndandOrigin set = new SetEndandOrigin();
public DataLine(){}

public DataLine(double o_x, double o_y, double e_x, double e_y)
{
setOrigin(o_x,o_y); setEnd(e_x,e_y);
}

public final DataLine setOrigin(double x, double y){
public final DataLine setOrigin(double x, double y){
originX = x; originY = y;
return this;
}

public final DataLine setEnd(double x, double y){
endX = x; endY = y;
return this;
Expand All @@ -49,12 +49,14 @@ public final DataLine setEnd(double x, double y){
public double getArrowSizeOrigin(){ return arrowSizeOrigin;}
public double getArrowSizeEnd(){ return arrowSizeEnd;}

public DataLine setArrowSizeOrigin(double size){
arrowSizeOrigin = size; return this;
public DataLine setArrowSizeOrigin(double size){
arrowSizeOrigin = set.setOrigin(size);
return this;
}

public DataLine setArrowSizeEnd(double size){
arrowSizeEnd = size; return this;
arrowSizeEnd = set.setOrigin(size);
return this;
}

public DataLine setLineColor(int color) { lineColor = color; return this;}
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/jlab/groot/data/H1F.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,7 @@ public static H1F create(String name, int bins, DataVector vec){
min = .9999*min;
max = 1.0001*max;
}
H1F h = new H1F(name,"",bins,min,max);
for(int i = 0; i < vec.getSize(); i++){
h.fill(vec.getValue(i));
}
h.setFillColor(43);
return h;
return getH1F(name, bins, min, max, vec);
}

public static H1F create(String name, int bins, DataVector vec, double min, double max){
Expand All @@ -260,13 +255,18 @@ public static H1F create(String name, int bins, DataVector vec, double min, dou
min = .9999*min;
max = 1.0001*max;
}
H1F h = new H1F(name,"",bins,min,max);
return getH1F(name, bins, min, max, vec);
}

private static H1F getH1F(String name, int bins, double min, double max, DataVector vec) {
H1F h = new H1F(name,"", bins, min, max);
for(int i = 0; i < vec.getSize(); i++){
h.fill(vec.getValue(i));
}
h.setFillColor(43);
h.setFillColor(43);
return h;
}

/**
* The getter for the histogram title.
* @return Title of the histogram.
Expand Down
68 changes: 5 additions & 63 deletions src/main/java/org/jlab/groot/data/H2F.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.IOException;
import java.util.ArrayList;

//import com.sun.org.apache.xerces.internal.impl.xpath.XPath;
import org.jlab.groot.base.DatasetAttributes;
import org.jlab.groot.base.GStyle;
import org.jlab.groot.math.Axis;
Expand All @@ -18,7 +19,7 @@
* @author Erin Kirby
* @version 061714
*/
public class H2F implements IDataSet {
public class H2F extends Axis implements IDataSet {

private String hName = "basic2D";
private Axis xAxis = new Axis();
Expand All @@ -33,8 +34,6 @@ public class H2F implements IDataSet {
private double maximumBinValue = 0.0;

public H2F() {
offset = new MultiIndex(xAxis.getNBins(), yAxis.getNBins());
hBuffer = new double[offset.getArraySize()];
initAttributes();
}

Expand All @@ -48,8 +47,6 @@ public H2F() {
*/
public H2F(String name) {
hName = name;
offset = new MultiIndex(xAxis.getNBins(), yAxis.getNBins());
hBuffer = new double[offset.getArraySize()];
initAttributes();

}
Expand Down Expand Up @@ -209,44 +206,7 @@ public double getMaximum(){
return maximum;
}

/**
* Checks if that bin is valid (exists)
*
* @param bx
* The x coordinate of the bin
* @param by
* The y coordinate of the bin
* @return The truth value of the validity of that bin
*/
private boolean isValidBins(int bx, int by) {
if ((bx >= 0) && (bx <= xAxis.getNBins()) && (by >= 0)
&& (by <= yAxis.getNBins())) {
return true;
}
return false;
}

/**
* Finds the bin content at that bin
*
* @param bx
* The x coordinate of the bin
* @param by
* The y coordinate of the bin
* @return The content at that bin
*/
public double getBinContent(int bx, int by) {
if (this.isValidBins(bx, by)) {
int buff = offset.getArrayIndex(bx, by);
if(buff>=0&&buff<hBuffer.length){
return hBuffer[buff];
} else {
System.out.println("[Index] error for binx = "+ bx +
" biny = " + by);
}
}
return 0.0;
}


public void modify(DataVector vecX, DataVector vecY, double xmin, double xmax, double ymin, double ymax){
int nbinsX = xAxis.getNBins();
Expand Down Expand Up @@ -337,7 +297,7 @@ public String getTitleY() {
* set Title of the histogram
* @param title new title
*/
public final void setTitle(String title){
public void setTitle(String title){

if(title.contains(";")==true){
String[] tokens = title.split(";");
Expand Down Expand Up @@ -816,25 +776,7 @@ public H1F sliceX(int xBin, H1F sliceX) {
}
return sliceX;
}
/**
* Creates a 1-D Histogram slice of the specified x Bin
*
* @param yBin the bin on the x axis to create a slice of
* @return a slice of the y bins on the specified x bin as a 1-D Histogram
*/
public H1F sliceY(int yBin) {
String name = "Slice of " + yBin + " Y Bin";
double xMin = xAxis.min();
double xMax = xAxis.max();
int xNum = xAxis.getNBins();
H1F sliceY = new H1F(name, name, xNum, xMin, xMax);

for (int y = 0; y < xNum; y++) {
sliceY.setBinContent(y, this.getBinContent(y,yBin));
}

return sliceY;
}


public float[] offset() {
float[] f = new float[hBuffer.length];
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/jlab/groot/data/SetEndandOrigin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.jlab.groot.data;

public class SetEndandOrigin {

public double setOrigin(double size){
return size;
}

public double setEnd(double size){
return size;
}
}
24 changes: 12 additions & 12 deletions src/main/java/org/jlab/groot/demo/MultiGaus.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public static void main(String[] args) {
h1[i].setTitleX("Randomly Generated Function");
h1[i].setTitleY("Counts");
h1[i].setOptStat(0);
F1D f1 = new F1D("f1","[amp]*gaus(x,[mean],[sigma])", -5.0, 5.0);
f1.setParameter(0, 120.0);
f1.setParameter(1, (-3.0 + rand.nextDouble() * 6));
f1.setParameter(2, .4 + (rand.nextDouble() * 1));
F1D frame1 = new F1D("frame1","[amp]*gaus(x,[mean],[sigma])", -5.0, 5.0);
frame1.setParameter(0, 120.0);
frame1.setParameter(1, (-3.0 + rand.nextDouble() * 6));
frame1.setParameter(2, .4 + (rand.nextDouble() * 1));

RandomFunc rndm = new RandomFunc(f1);
RandomFunc rndm = new RandomFunc(frame1);
for (int j = 0; j < 34000; j++) {
h1[i].fill(rndm.random());
}
Expand All @@ -48,17 +48,17 @@ public static void main(String[] args) {
optStatString +="1";
}
optStatString+="00";
f1.setOptStat(Integer.parseInt(optStatString));
frame1.setOptStat(Integer.parseInt(optStatString));

c1.getPad(i).getAxisX().setRange(-6.0, 5.0);
c1.draw(h1[i]);

f1.setParameter(0, h1[i].getEntries()); //Due to initial parameter estimates not existing
DataFitter.fit(f1, h1[i], "Q"); //No options uses error for sigma
c1.draw(f1,"same");
f1.setLineColor(30 + (i % 4) + 2);
f1.setLineWidth(3);
f1.setLineStyle(i%4);
frame1.setParameter(0, h1[i].getEntries()); //Due to initial parameter estimates not existing
DataFitter.fit(frame1, h1[i], "Q"); //No options uses error for sigma
c1.draw(frame1,"same");
frame1.setLineColor(30 + (i % 4) + 2);
frame1.setLineWidth(3);
frame1.setLineStyle(i%4);
c1.setFont("HanziPen TC");
c1.setTitleSize(16);
c1.setAxisTitleSize(14);
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/org/jlab/groot/graphics/EmbeddedCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.jlab.groot.fitter.ParallelSliceFitter;
import org.jlab.groot.group.DataGroup;
import org.jlab.groot.math.Dimension1D;
import org.jlab.groot.math.F1D;
import org.jlab.groot.math.FunctionFactory;
import org.jlab.groot.ui.FitPanel;
import org.jlab.groot.ui.LatexText;
Expand Down Expand Up @@ -332,15 +331,15 @@ public void paint(Graphics g) {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);

int w = this.getSize().width;
int h = this.getSize().height;
int width = this.getSize().width;
int height = this.getSize().height;

g2d.setColor(GStyle.getCanvasBackgroundColor());

//g2d.setColor(Color.WHITE);
// g2d.setColor(new Color(230,230,230));
g2d.fillRect(0, 0, w, h);
updateCanvasPads(w, h);
g2d.fillRect(0, 0, width, height);
updateCanvasPads(width, height);

PadMargins margins = new PadMargins();
//System.out.println(" margins ");
Expand All @@ -353,7 +352,7 @@ public void paint(Graphics g) {

for (int i = 0; i < canvasPads.size(); i++) {
EmbeddedPad pad = canvasPads.get(i);
//pad.setDimension(0, 0, w, h);
//pad.setDimension(0, 0, width, height);
//System.out.println("PAD " + i + " " + pad.getAxisFrame().getFrameMargins());
//pad.getAxisFrame().setAxisMargins(pad.getAxisFrame().getFrameMargins());
//System.out.println(pad.getAxisFrame().getFrameMargins());
Expand Down
Loading