public MatrixZoomData getControlZd() { Matrix matrix = getControlMatrix(); if (matrix == null || currentZoom == null) { return null; } else { return matrix.getZoomData(currentZoom); } }
public MatrixZoomData getZd() throws UninitializedObjectException { Matrix matrix = getMatrix(); if (matrix == null) { throw new UninitializedObjectException("Uninitialized matrix"); } else if (currentZoom == null) { throw new UninitializedObjectException("Uninitialized zoom"); } else { return matrix.getZoomData(currentZoom); } }
public void applyMatricesToVertices(MDL mdlr) { int sz = numVerteces(); for (int i = 0; i < sz; i++) { GeosetVertex gv = vertex.get(i); gv.clearBoneAttachments(); Matrix mx = getMatrix(gv.getVertexGroup()); mx.updateIds(mdlr); int szmx = mx.size(); for (int m = 0; m < szmx; m++) { gv.addBoneAttachment((Bone) mdlr.getIdObject(mx.getBoneId(m))); } } }
public void applyVerticesToMatrices(MDL mdlr) { matrix.clear(); for (int i = 0; i < vertex.size(); i++) { Matrix newTemp = new Matrix(vertex.get(i).bones); boolean newMatrix = true; for (int m = 0; m < matrix.size() && newMatrix; m++) { if (newTemp.equals(matrix.get(m))) { newTemp = matrix.get(m); newMatrix = false; } } if (newMatrix) { matrix.add(newTemp); newTemp.updateIds(mdlr); } vertex.get(i).VertexGroup = matrix.indexOf(newTemp); vertex.get(i).setMatrix(newTemp); } }
private void unsafeSave1DTrackToWigFile( Chromosome chromosomeForPosition, PrintWriter printWriter, int binStartPosition) throws IOException { int resolution = getZoom().getBinSize(); for (Chromosome chromosome : chromosomes) { if (chromosome.getName().equals(Globals.CHR_ALL)) continue; Matrix matrix = null; if (displayOption == MatrixType.OBSERVED) { matrix = dataset.getMatrix(chromosomeForPosition, chromosome); } else if (displayOption == MatrixType.CONTROL) { matrix = controlDataset.getMatrix(chromosomeForPosition, chromosome); } if (matrix == null) continue; MatrixZoomData zd = matrix.getZoomData(currentZoom); printWriter.println( "fixedStep chrom=chr" + chromosome.getName().replace("chr", "") + " start=1 step=" + resolution + " span=" + resolution); int[] regionIndices; if (chromosomeForPosition.getIndex() < chromosome.getIndex()) { regionIndices = new int[] {binStartPosition, binStartPosition, 0, chromosome.getLength()}; } else { regionIndices = new int[] {0, chromosome.getLength(), binStartPosition, binStartPosition}; } zd.dump1DTrackFromCrossHairAsWig( printWriter, chromosomeForPosition, binStartPosition, chromosomeForPosition.getIndex() == chromosome.getIndex(), regionIndices, normalizationType, displayOption, getExpectedValues()); } }
public static void main(String[] args) throws Exception { fw = new FileWriter("/Users/Main/Desktop/test.csv", false); // ※1 pw = new PrintWriter(new BufferedWriter(fw)); for (range = 1; range < 1000000; range *= 2) { for (int j = 0; j < 3; j++) { for (int i = 0; i < 1; i++) { Vector X = Vector.generate(n, range); Matrix A = Matrix.generate(n, n, range); Vector B = A.multi(X); pw.print(range); pw.print(","); pw.print(n); System.out.println(n); analysisGaussianEliminationWithPivot(A, B, X); System.out.println(); } } } pw.close(); }
public void updateToObjects(MDL mdlr) { // upload the temporary UVLayer and Matrix objects into the vertices themselves int sz = numVerteces(); for (Matrix m : matrix) { m.updateBones(mdlr); } for (int i = 0; i < sz; i++) { GeosetVertex gv = vertex.get(i); gv.clearTVerts(); int szuv = uvlayers.size(); for (int l = 0; l < szuv; l++) { try { gv.addTVertex(uvlayers.get(l).getTVertex(i)); } catch (Exception e) { JOptionPane.showMessageDialog( MDLReader.getDefaultContainer(), "Error: Length of TVertices and Vertices chunk differ (Or some other unknown error has occurred)!"); } } Matrix mx = getMatrix(gv.getVertexGroup()); int szmx = mx.size(); gv.clearBoneAttachments(); for (int m = 0; m < szmx; m++) { gv.addBoneAttachment((Bone) mdlr.getIdObject(mx.getBoneId(m))); } gv.setNormal(normals.get(i)); for (Triangle t : triangle) { if (t.containsRef(gv)) { gv.triangles.add(t); } } gv.geoset = this; // gv.addBoneAttachment(null);//Why was this here? } try { material = mdlr.getMaterial(materialID); } catch (ArrayIndexOutOfBoundsException e) { JOptionPane.showMessageDialog(null, "Error: Material index out of bounds for geoset!"); } parentModel = mdlr; }
/** * Compute the bounding screen extent of a rotated rectangle. * * @param rect Rectangle to rotate. * @param x X coordinate of the rotation point. * @param y Y coordinate of the rotation point. * @param rotation Rotation angle. * @return The smallest rectangle that completely contains {@code rect} when rotated by the * specified angle. */ protected Rectangle computeRotatedScreenExtent(Rectangle rect, int x, int y, Angle rotation) { Rectangle r = new Rectangle(rect); // Translate the rectangle to the rotation point. r.translate(-x, -y); // Compute corner points Vec4[] corners = { new Vec4(r.getMaxX(), r.getMaxY()), new Vec4(r.getMaxX(), r.getMinY()), new Vec4(r.getMinX(), r.getMaxY()), new Vec4(r.getMinX(), r.getMinY()) }; // Rotate the rectangle Matrix rotationMatrix = Matrix.fromRotationZ(rotation); for (int i = 0; i < corners.length; i++) { corners[i] = corners[i].transformBy3(rotationMatrix); } // Find the bounding rectangle of rotated points. int minX = Integer.MAX_VALUE; int minY = Integer.MAX_VALUE; int maxX = -Integer.MAX_VALUE; int maxY = -Integer.MAX_VALUE; for (Vec4 v : corners) { if (v.x > maxX) maxX = (int) v.x; if (v.x < minX) minX = (int) v.x; if (v.y > maxY) maxY = (int) v.y; if (v.y < minY) minY = (int) v.y; } // Set bounds and translate the rectangle back to where it started. r.setBounds(minX, minY, maxX - minX, maxY - minY); r.translate(x, y); return r; }
public static void analysisGaussianEliminationWithPivot(Matrix A, Vector B, Vector X) { System.out.println("GaussianElimination"); pw.print(","); pw.print("GaussianElimination"); analysis( X, () -> { try { return Algorithm.gaussianEliminationWithPivot(A.toDoubleArray(), B.toDoubleArray()); } catch (Exception e) { e.printStackTrace(); pw.print(","); pw.print("-"); pw.print(","); pw.print("-"); pw.println(); return new double[0]; } }); }
public void doSavePrep(MDL mdlr) { purifyFaces(); // Normals cleared here, in case that becomes a problem later. normals.clear(); // UV Layers cleared here uvlayers.clear(); int bigNum = 0; int littleNum = -1; for (int i = 0; i < vertex.size(); i++) { int temp = vertex.get(i).tverts.size(); if (temp > bigNum) { bigNum = temp; } if (littleNum == -1 || temp < littleNum) { littleNum = temp; } } if (littleNum != bigNum) { JOptionPane.showMessageDialog( null, "Error: Attempting to save a Geoset with Verteces that have differing numbers of TVertices! Empty TVertices will be autogenerated."); } for (int i = 0; i < bigNum; i++) { uvlayers.add(new UVLayer()); } for (int i = 0; i < vertex.size(); i++) { normals.add(vertex.get(i).getNormal()); for (int uv = 0; uv < bigNum; uv++) { TVertex temp = vertex.get(i).getTVertex(uv); if (temp != null) { uvlayers.get(uv).addTVertex(temp); } else { uvlayers.get(uv).addTVertex(new TVertex(0, 0)); } } } // Clearing matrix list matrix.clear(); for (int i = 0; i < vertex.size(); i++) { Matrix newTemp = new Matrix(vertex.get(i).bones); boolean newMatrix = true; for (int m = 0; m < matrix.size() && newMatrix; m++) { if (newTemp.equals(matrix.get(m))) { newTemp = matrix.get(m); newMatrix = false; } } if (newMatrix) { matrix.add(newTemp); newTemp.updateIds(mdlr); } vertex.get(i).VertexGroup = matrix.indexOf(newTemp); vertex.get(i).setMatrix(newTemp); } for (int i = 0; i < triangle.size(); i++) { triangle.get(i).updateVertexIds(this); } int boneRefCount = 0; for (int i = 0; i < matrix.size(); i++) { boneRefCount += matrix.get(i).bones.size(); } for (int i = 0; i < matrix.size(); i++) { matrix.get(i).updateIds(mdlr); } }
public void printTo(PrintWriter writer, MDL mdlr, boolean trianglesTogether) { purifyFaces(); writer.println("Geoset {"); writer.println("\tVertices " + vertex.size() + " {"); String tabs = "\t\t"; // Normals cleared here, in case that becomes a problem later. normals.clear(); // UV Layers cleared here uvlayers.clear(); int bigNum = 0; int littleNum = -1; for (int i = 0; i < vertex.size(); i++) { int temp = vertex.get(i).tverts.size(); if (temp > bigNum) { bigNum = temp; } if (littleNum == -1 || temp < littleNum) { littleNum = temp; } } if (littleNum != bigNum) { JOptionPane.showMessageDialog( null, "Error: Attempting to save a Geoset with Verteces that have differing numbers of TVertices! Empty TVertices will be autogenerated."); } for (int i = 0; i < bigNum; i++) { uvlayers.add(new UVLayer()); } for (int i = 0; i < vertex.size(); i++) { writer.println(tabs + vertex.get(i).toString() + ","); normals.add(vertex.get(i).getNormal()); for (int uv = 0; uv < bigNum; uv++) { try { TVertex temp = vertex.get(i).getTVertex(uv); if (temp != null) { uvlayers.get(uv).addTVertex(temp); } else { uvlayers.get(uv).addTVertex(new TVertex(0, 0)); } } catch (IndexOutOfBoundsException e) { uvlayers.get(uv).addTVertex(new TVertex(0, 0)); } } } writer.println("\t}"); writer.println("\tNormals " + normals.size() + " {"); for (int i = 0; i < normals.size(); i++) { writer.println(tabs + normals.get(i).toString() + ","); } writer.println("\t}"); for (int i = 0; i < uvlayers.size(); i++) { uvlayers.get(i).printTo(writer, 1, true); } // Clearing matrix list matrix.clear(); writer.println("\tVertexGroup {"); for (int i = 0; i < vertex.size(); i++) { Matrix newTemp = new Matrix(vertex.get(i).bones); boolean newMatrix = true; for (int m = 0; m < matrix.size() && newMatrix; m++) { if (newTemp.equals(matrix.get(m))) { newTemp = matrix.get(m); newMatrix = false; } } if (newMatrix) { matrix.add(newTemp); newTemp.updateIds(mdlr); } vertex.get(i).VertexGroup = matrix.indexOf(newTemp); vertex.get(i).setMatrix(newTemp); writer.println(tabs + vertex.get(i).VertexGroup + ","); } writer.println("\t}"); if (trianglesTogether) { writer.println("\tFaces 1 " + (triangle.size() * 3) + " {"); writer.println("\t\tTriangles {"); String triangleOut = "\t\t\t{ "; for (int i = 0; i < triangle.size(); i++) { triangle.get(i).updateVertexIds(this); if (i != triangle.size() - 1) { triangleOut = triangleOut + triangle.get(i).toString() + ", "; } else { triangleOut = triangleOut + triangle.get(i).toString() + " "; } } writer.println(triangleOut + "},"); writer.println("\t\t}"); } else { writer.println("\tFaces " + triangle.size() + " " + (triangle.size() * 3) + " {"); writer.println("\t\tTriangles {"); String triangleOut = "\t\t\t{ "; for (int i = 0; i < triangle.size(); i++) { triangle.get(i).updateVertexIds(this); writer.println(triangleOut + triangle.get(i).toString() + " },"); } writer.println("\t\t}"); } writer.println("\t}"); int boneRefCount = 0; for (int i = 0; i < matrix.size(); i++) { boneRefCount += matrix.get(i).bones.size(); } writer.println("\tGroups " + matrix.size() + " " + boneRefCount + " {"); for (int i = 0; i < matrix.size(); i++) { matrix.get(i).updateIds(mdlr); matrix.get(i).printTo(writer, 2); // 2 is the tab height } writer.println("\t}"); if (extents != null) extents.printTo(writer, 1); for (int i = 0; i < anims.size(); i++) { anims.get(i).printTo(writer, 1); } writer.println("\tMaterialID " + materialID + ","); writer.println("\tSelectionGroup " + selectionGroup + ","); for (int i = 0; i < flags.size(); i++) { writer.println("\t" + flags.get(i) + ","); } writer.println("}"); }
public static Geoset read(BufferedReader mdl) { String line = MDLReader.nextLine(mdl); System.out.println("geo begins with " + line); if (line.contains("Geoset")) { line = MDLReader.nextLine(mdl); Geoset geo = new Geoset(); if (!line.contains("Vertices")) { JOptionPane.showMessageDialog( MDLReader.getDefaultContainer(), "Error: Vertices not found at beginning of Geoset!"); } while (!((line = MDLReader.nextLine(mdl)).contains("\t}"))) { geo.addVertex(GeosetVertex.parseText(line)); } line = MDLReader.nextLine(mdl); if (line.contains("Normals")) { // If we have normals: while (!((line = MDLReader.nextLine(mdl)).contains("\t}"))) { geo.addNormal(Normal.parseText(line)); } } while (((line = MDLReader.nextLine(mdl)).contains("TVertices"))) { geo.addUVLayer(UVLayer.read(mdl)); } if (!line.contains("VertexGroup")) { JOptionPane.showMessageDialog( MDLReader.getDefaultContainer(), "Error: VertexGroups missing or invalid!"); } int i = 0; while (!((line = MDLReader.nextLine(mdl)).contains("\t}"))) { geo.getVertex(i).setVertexGroup(MDLReader.readInt(line)); i++; } line = MDLReader.nextLine(mdl); if (!line.contains("Faces")) { JOptionPane.showMessageDialog( MDLReader.getDefaultContainer(), "Error: Faces missing or invalid!"); } line = MDLReader.nextLine(mdl); if (!line.contains("Triangles")) { System.out.println(line); JOptionPane.showMessageDialog( MDLReader.getDefaultContainer(), "Error: Triangles missing or invalid!"); } geo.setTriangles(Triangle.read(mdl, geo)); line = MDLReader.nextLine(mdl); // Throw away the \t} closer for faces line = MDLReader.nextLine(mdl); if (!line.contains("Groups")) { JOptionPane.showMessageDialog( MDLReader.getDefaultContainer(), "Error: Groups (Matrices) missing or invalid!"); } while (!((line = MDLReader.nextLine(mdl)).contains("\t}"))) { geo.addMatrix(Matrix.parseText(line)); } MDLReader.mark(mdl); line = MDLReader.nextLine(mdl); while (!line.contains("}") || line.contains("},")) { if (line.contains("Extent") || line.contains("BoundsRadius")) { System.out.println("Parsing geoset extLog:" + line); MDLReader.reset(mdl); geo.setExtLog(ExtLog.read(mdl)); System.out.println("Completed geoset extLog."); } else if (line.contains("Anim")) { MDLReader.reset(mdl); geo.add(Animation.read(mdl)); MDLReader.mark(mdl); } else if (line.contains("MaterialID")) { geo.materialID = MDLReader.readInt(line); MDLReader.mark(mdl); } else if (line.contains("SelectionGroup")) { geo.selectionGroup = MDLReader.readInt(line); MDLReader.mark(mdl); } else { geo.addFlag(MDLReader.readFlag(line)); System.out.println("Reading to geoFlag: " + line); MDLReader.mark(mdl); } line = MDLReader.nextLine(mdl); } // JOptionPane.showMessageDialog(MDLReader.getDefaultContainer(),"Geoset reading // completed!"); System.out.println("Geoset reading completed!"); return geo; } else { JOptionPane.showMessageDialog( MDLReader.getDefaultContainer(), "Unable to parse Geoset: Missing or unrecognized open statement '" + line + "'."); } return null; }
private static void addSprites(Compositor sh) throws IOException, QTException { File matchFile = QTFactory.findAbsolutePath("images/Ship01.pct"); // this file must exist in the directory!!! ImageDataSequence isp = ImageUtil.createSequence(matchFile); ImageDataSequence seq = ImageUtil.makeTransparent(isp, QDColor.blue); // Build Sprites Matrix matrix1 = new Matrix(); matrix1.setTx(20); matrix1.setTy(20); matrix1.setSx(0.8F); matrix1.setSy(0.8F); TwoDSprite s1 = new TwoDSprite(seq, 4, matrix1, true, 1); sh.addMember(s1); Matrix matrix2 = new Matrix(); matrix2.setTx(4); matrix2.setTy(4); TwoDSprite s2 = new TwoDSprite(seq, 1, matrix2, true, 10); sh.addMember(s2); // This needs to be a 32bit QDGraphics so the blend mode will // be applied correctly to this sprite File shipFile = QTFactory.findAbsolutePath("images/Ship10.pct"); GraphicsImporterDrawer ip = new GraphicsImporterDrawer(new QTFile(shipFile)); QDRect r = new QDRect(ip.getDescription().getWidth(), ip.getDescription().getHeight()); ImageSpec si = ImageUtil.makeTransparent( ip, QDColor.blue, new QDGraphics(QDGraphics.kDefaultPixelFormat, r)); Matrix matrix3 = new Matrix(); matrix3.setTx(50); matrix3.setTy(50); TwoDSprite s3 = new TwoDSprite(si, matrix3, true, 8, new GraphicsMode(QDConstants.blend, QDColor.green)); sh.addMember(s3); // Add Dragger (DEPRECATED CODE) /* Dragger dragger = new Dragger (InputEvent.SHIFT_MASK); SWController controller = new SWController (dragger, true); sh.addController (controller);*/ QTMouseTargetController shipController = new QTMouseTargetController(true); shipController.addQTMouseListener( new DragAction(new TranslateMatrix()) { // only activates when the shift modifier is pressed public boolean matchModifierFilter(int mods) { if ((mods & 0xF) == QTConstants.kJavaShiftMask) return true; return false; } }); sh.addController(shipController); // Add Controllers // Build ActionList SimpleActionList al = new SimpleActionList(); ImageSequencer is = new ImageSequencer(seq); is.setLooping(ImageSequencer.kLoopForwards); al.addMember(new NextImageAction(10, 1, is, s1)); al.addMember(new BounceAction(5, 1, sh, s1, 3, 2)); ImageSequencer is2 = new ImageSequencer(seq); is2.setLooping(ImageSequencer.kLoopForwards); al.addMember(new NextImageAction(20, 1, is2, s2)); al.addMember(new BounceAction(20, 1, sh, s2, 4, 3)); sh.addController(al); }
/** * Compute the label's screen position from its geographic position. * * @param dc Current draw context. */ protected void computeGeometry(DrawContext dc) { // Project the label position onto the viewport Position pos = this.getPosition(); if (pos == null) return; this.placePoint = dc.computeTerrainPoint(pos.getLatitude(), pos.getLongitude(), 0); this.screenPlacePoint = dc.getView().project(this.placePoint); this.eyeDistance = this.placePoint.distanceTo3(dc.getView().getEyePoint()); boolean orientationReversed = false; if (this.orientationPosition != null) { // Project the orientation point onto the screen Vec4 orientationPlacePoint = dc.computeTerrainPoint( this.orientationPosition.getLatitude(), this.orientationPosition.getLongitude(), 0); Vec4 orientationScreenPoint = dc.getView().project(orientationPlacePoint); this.rotation = this.computeRotation(this.screenPlacePoint, orientationScreenPoint); // The orientation is reversed if the orientation point falls to the right of the screen // point. Text is // never drawn upside down, so when the orientation is reversed the text flips vertically to // keep the text // right side up. orientationReversed = (orientationScreenPoint.x <= this.screenPlacePoint.x); } this.computeBoundsIfNeeded(dc); Offset offset = this.getOffset(); Point2D offsetPoint = offset.computeOffset(this.bounds.getWidth(), this.bounds.getHeight(), null, null); // If a rotation is applied to the text, then rotate the offset as well. An offset in the x // direction // will move the text along the orientation line, and a offset in the y direction will move the // text // perpendicular to the orientation line. if (this.rotation != null) { double dy = offsetPoint.getY(); // If the orientation is reversed we need to adjust the vertical offset to compensate for the // flipped // text. For example, if the offset normally aligns the top of the text with the place point // then without // this adjustment the bottom of the text would align with the place point when the // orientation is // reversed. if (orientationReversed) { dy = -(dy + this.bounds.getHeight()); } Vec4 pOffset = new Vec4(offsetPoint.getX(), dy); Matrix rot = Matrix.fromRotationZ(this.rotation.multiply(-1)); pOffset = pOffset.transformBy3(rot); offsetPoint = new Point((int) pOffset.getX(), (int) pOffset.getY()); } int x = (int) (this.screenPlacePoint.x + offsetPoint.getX()); int y = (int) (this.screenPlacePoint.y - offsetPoint.getY()); this.screenPoint = new Point(x, y); this.screenExtent = this.computeTextExtent(x, y, this.rotation); }
/** * Constructor * * @param f1 FPoint2 * @param f2 FPoint2 * @param pt FPoint2, or null for bisector */ private void construct(FPoint2 f1, FPoint2 f2, FPoint2 pt) { // userData[LEFT] = new DArray(); // userData[RIGHT] =new DArray(); final boolean db = false; if (db) { System.out.println("Hyperbola constructor\n f1=" + f1 + "\n f2=" + f2 + "\n pt=" + pt); } boolean bisector = (pt == null); initializeVisibleSegments(); // if point on arm is closer to f2 than f1, swap f1 & f2. if (!bisector && FPoint2.distanceSquared(f1, pt) > FPoint2.distanceSquared(f2, pt)) { flipped = true; } this.foci[RIGHT] = new FPoint2(f1); this.foci[LEFT] = new FPoint2(f2); if (!bisector) { this.pt = new FPoint2(pt); } double fociDist = FPoint2.distance(f1, f2); if (fociDist == 0) { throw new FPError("Hyperbola foci are same point"); } c = fociDist * .5; // calculate the translation of the hyperbola away from // standard position. FPoint2 rFocus = getFocus(0), lFocus = getFocus(1); origin = new FPoint2(.5 * (rFocus.x + lFocus.x), .5 * (rFocus.y + lFocus.y)); // calculate the angle of rotation of the hyperbola away // from the standard position. double theta = Math.atan2(rFocus.y - lFocus.y, rFocus.x - lFocus.x); Matrix fromCenterInW = Matrix.getTranslate(origin, true); Matrix rotToE = Matrix.getRotate(-theta); toE2 = rotToE; Matrix.mult(toE2, fromCenterInW, toE2); // calculate inverse toW2 = toE2.invert(null); // Matrix toCenterInW = Matrix.translationMatrix(origin, false); // Matrix rotToW = Matrix.getRotate2D(theta); // // toW2 = toCenterInW; // Matrix.mult(toW2, rotToW, toW2); // Tools.warn("just invert matrix here"); // if (bisector) { valid = true; } else { // get the arm point in hyperbola space. FPoint2 workPt = toE2.apply(pt, null); double xs = workPt.x * workPt.x; double cs = c * c; Polyn q = new Polyn(1, -(cs + xs + workPt.y * workPt.y), cs * xs); if (db) { System.out.println("a2 quadratic:\n" + q); } final DArray qsoln = new DArray(); q.solve(qsoln); if (db) { Streams.out.println(qsoln); } double val = q.c(1) * -.5; int ql = qsoln.size(); if (ql >= 1) { val = qsoln.getDouble(0); } // choose the root that is less than c*c. if (ql == 2) { if (val > qsoln.getDouble(1)) { val = qsoln.getDouble(1); if (db) { System.out.println(" two roots, choosing smaller."); } } } if (db) { System.out.println(" root chosen=" + val); } a = Polyn.sqrt(val); A = a * a; B = A / (c * c - A); } valid = true; if (db) { System.out.println(" ==> " + this); } }
/** * ************************************************************* Official Method for setting the * zoom and location for heatmap DO NOT IMPLEMENT A NEW FUNCTION Make the necessary * customizations, then call this function * ************************************************************* * * @param newZoom * @param genomeX * @param genomeY * @param scaleFactor (pass -1 if scaleFactor should be calculated) * @return */ public boolean unsafeActuallySetZoomAndLocation( String chrXName, String chrYName, HiCZoom newZoom, int genomeX, int genomeY, double scaleFactor, boolean resetZoom, ZoomCallType zoomCallType, boolean allowLocationBroadcast) { if (dataset == null) return false; // No data in view // Check this zoom operation is possible, if not, fail it here: // if (superAdapter.testNewZoom(newZoom)) // { // return false; // } // String chr1OriginalName = xContext.getChromosome().getName(); // String chr2OriginalName = yContext.getChromosome().getName(); if (chrXName.length() > 0 && chrYName.length() > 0) { setChromosomesFromBroadcast(chrXName, chrYName); // We might end with All->All view, make sure normalization state is updates accordingly... superAdapter.getMainViewPanel().setNormalizationDisplayState(superAdapter.getHiC()); } if (newZoom == null) { System.err.println("Invalid zoom " + newZoom); } Chromosome chr1 = xContext.getChromosome(); Chromosome chr2 = yContext.getChromosome(); final Matrix matrix = dataset.getMatrix(chr1, chr2); if (matrix == null) { superAdapter.launchGenericMessageDialog( "Sorry, this region is not available", "Matrix unavailable", JOptionPane.WARNING_MESSAGE); return false; } MatrixZoomData newZD = matrix.getZoomData(newZoom); if (HiCFileTools.isAllChromosome(chr1)) { newZD = matrix.getFirstZoomData(Unit.BP); } if (newZD == null) { superAdapter.launchGenericMessageDialog( "Sorry, this zoom is not available", "Zoom unavailable", JOptionPane.WARNING_MESSAGE); return false; } /* TODO Undo Zoom implementation mss2 _UZI if(currentZoom != null) { tempZoomState = new ZoomState(chr1OriginalName, chr2OriginalName, currentZoom.clone(), (int) xContext.getBinOrigin(), (int) yContext.getBinOrigin(), getScaleFactor(), resetZoom, ZoomCallType.GOTO); } */ currentZoom = newZoom; xContext.setZoom(currentZoom); yContext.setZoom(currentZoom); if (scaleFactor > 0) { setScaleFactor(scaleFactor); } else { int maxBinCount = Math.max(newZD.getXGridAxis().getBinCount(), newZD.getYGridAxis().getBinCount()); double defaultScaleFactor = Math.max( 1.0, (double) superAdapter.getHeatmapPanel().getMinimumDimension() / maxBinCount); setScaleFactor(defaultScaleFactor); } int binX = newZD.getXGridAxis().getBinNumberForGenomicPosition(genomeX); int binY = newZD.getYGridAxis().getBinNumberForGenomicPosition(genomeY); switch (zoomCallType) { case INITIAL: case STANDARD: center(binX, binY); break; case DRAG: xContext.setBinOrigin(binX); yContext.setBinOrigin(binY); break; case DIRECT: xContext.setBinOrigin(genomeX); yContext.setBinOrigin(genomeY); break; } // Notify HeatmapPanel render that zoom has changed. Render should update zoom slider once with // previous range values setZoomChanged(); if (resetZoom) { superAdapter.updateAndResetZoom(newZoom); } else { superAdapter.updateZoom(newZoom); } superAdapter.refresh(); if (linkedMode && allowLocationBroadcast) { broadcastLocation(); } /* TODO Undo Zoom implementation mss2 _UZI if(zoomCallType == ZoomCallType.INITIAL || tempZoomState == null || chrXName.equals(Globals.CHR_ALL) || chrYName.equals(Globals.CHR_ALL) || tempZoomState.chr1Name.equals(Globals.CHR_ALL) || tempZoomState.chr2Name.equals(Globals.CHR_ALL)){ canRedoZoomChange = false; canUndoZoomChange = false; } else { // defauts for a normal zoom operation canRedoZoomChange = false; canUndoZoomChange = true; previousZoomState = tempZoomState; } */ return true; }