public void actionPerformed(ActionEvent event) { int value = Integer.parseInt(numcontours.getText()); cv1.setContours(value); numcontours.setText(Integer.toString(value)); } });
/** * Adds a contours view with the function f(x1,x2). * Function f(x1,x2) assumed to have uniform sampling. * @param irow the tile row index. * @param icol the tile column index. * @param f array[n2][n1] of sampline function values f(x1,x2), where * n1 = f[0].length and n2 = f.length. * @return a contours view. */ public ContoursView addContours(int irow, int icol, float[][] f) { ContoursView cv = new ContoursView(f); return addContoursView(irow,icol,cv); }
for (i2=0; i2<n2; ++i2) { for (i1=0; i1<n1; ++i1) { if (i2<n2m1 && between(fc,f[i2][i1],f[i2+1][i1])) { setw(i1,i2,flags); ++ni; if (i1<n1m1 && between(fc,f[i2][i1],f[i2][i1+1])) { sets(i1,i2,flags); ++ni; if (sset(i1,i2,flags)) { float d = delta(fc,f[i2][i1],f[i2][i1+1]); FloatList x1 = new FloatList(); FloatList x2 = new FloatList(); x1.add(f1+(i1+d)*d1); x2.add(f2+(i2 )*d2); clrs(i1,i2,flags); for (i=is-n1; i>=0; i=connect(i,fc,n1,d1,f1,n2,d2,f2,f,flags,x1,x2)) --ni; c.append(x1,x2); if (wset(i1,i2,flags)) { float d = delta(fc,f[i2][i1],f[i2+1][i1]); FloatList x1 = new FloatList(); FloatList x2 = new FloatList(); x1.add(f1+(i1 )*d1); x2.add(f2+(i2+d)*d2); clrw(i1,i2,flags); for (i=is-1; i>=0; i=connect(i,fc,n1,d1,f1,n2,d2,f2,f,flags,x1,x2))
public void paint(Graphics2D g2d) { updateContourSampling(); updateContours(); Projector hp = getHorizontalProjector(); Projector vp = getVerticalProjector(); Transcaler ts = getTranscaler(); int[] xcon = new int[xc1.length]; int[] ycon = new int[xc2.length]; computeXY(hp,vp,ts,n,xc1,xc2,xcon,ycon); if (gline!=null) gline.drawPolyline(xcon,ycon,n);
if (sset(i1,i2+1,flags)) { float d = delta(fc,f[i2+1][i1],f[i2+1][i1+1]); x1.add(f1+(i1+d)*d1); x2.add(f2+(i2+1)*d2); clrs(i1,++i2,flags); return (i2<n2-1)?index+n1:-1; else if (wset(i1+1,i2,flags)) { float d = delta(fc,f[i2][i1+1],f[i2+1][i1+1]); x1.add(f1+(i1+1)*d1); x2.add(f2+(i2+d)*d2); clrw(++i1,i2,flags); return (i1<n1-1)?index+1:-1; else if (sset(i1,i2,flags)) { float d = delta(fc,f[i2][i1],f[i2][i1+1]); x1.add(f1+(i1+d)*d1); x2.add(f2+(i2 )*d2); clrs(i1,i2,flags); return (i2>0)?index-n1:-1; else if (wset(i1,i2,flags)) { float d = delta(fc,f[i2][i1],f[i2+1][i1]); x1.add(f1+(i1 )*d1); x2.add(f2+(i2+d)*d2); clrw(i1,i2,flags); return (i1>0)?index-1:-1;
cv1.setLineStyleNegative(ContoursView.Line.DASH); cv1.setLineColor(Color.BLACK); cv1.setContours(50);
/** * Sets the contour values to those in the specified array. * If this method is called, then clips (or percentiles) are not used * to determine contour values, and readable contours are disabled. * @param c the array of contour values. */ public void setContours(float[] c) { double[] cd = new double[c.length]; for (int i=0; i<c.length; ++i) cd[i] = (double)c[i]; setContours(new Sampling(cd)); }
/** * Adds a contours view of the specified sampled function f(x1,x2). * @param irow the tile row index. * @param icol the tile column index. * @param s1 the sampling of the variable x1; must be uniform. * @param s2 the sampling of the variable x2; must be uniform. * @param f array[n2][n1] of sampled function values f(x1,x2), * where n1 = f[0].length and n2 = f.length. * @return the contours view. */ public ContoursView addContours( int irow, int icol, Sampling s1, Sampling s2, float[][] f) { ContoursView cv = new ContoursView(s1,s2,f); return addContoursView(irow,icol,cv); }