affinetransform

Graphics Context misaligned on first paint

旧时模样 提交于 2019-11-26 18:33:56
问题 I've been working up an answer for another question and came across a bizare issue that I've not seen before... Basically, the program uses a AffineTransform to provide translation, scaling and rotating of a Graphics element, simple enough stuff, done a thousand times before The problem is, when the screen first appears, the output is not where it should be, but once I touch one of the controls (adjust one of the slides) it jumps to the right spot. Based on the screen shots, the Graphics

Rotating Image with AffineTransform

只愿长相守 提交于 2019-11-26 12:32:36
I have got class called Airplane . Inside this class i have got variable img which is a BufferedImage type. What is more i have got class WorldMap which overrides function paintComponent(Graphics g) : @Override public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.drawImage(mapa, 0, 0, getWidth(), getHeight(), null); drawAirplanes(g2d); } Function drawAirplanes() look like this: private void drawAirplane(Graphics2D g){ for(Samolot i: s){ i.rotateAirplane(); g.drawImage(i.getImg(),i.getX(),i.getY(),(int)i.getDim().getWidth(),(int)i.getDim().getHeight(), null); } } It

AffineTransform.rotate() - how do I xlate, rotate, and scale at the same time?

吃可爱长大的小学妹 提交于 2019-11-26 11:39:47
问题 I have the following code which does (the first part of) what I want drawing a chessboard with some pieces on it. Image pieceImage = getImage(currentPiece); int pieceHeight = pieceImage.getHeight(null); double scale = (double)side/(double)pieceHeight; AffineTransform transform = new AffineTransform(); transform.setToTranslation(xPos, yPos); transform.scale(scale, scale); realGraphics.drawImage(pieceImage, transform, this); that is, it gets a chess piece\'s image and the image\'s height, it

rotating coordinate plane for data and text in Java

♀尐吖头ヾ 提交于 2019-11-26 03:16:46
问题 I need to: 1.) move the origin and also rotate the coordinate plane so that x-values progress rightward and y-values progress upward from the new origin(which needs to be the bottom left corner of the inner, blue rectangle in the code below). This will enable me to plot points at x,y coordinate pairs in the code below. 2.) plot rotated labels for the tic marks on the y-axis of the data plot. The code below sets up this problem. It works, except for two problems: 1.) the data points are being

Moving objects and timers

*爱你&永不变心* 提交于 2019-11-26 00:39:05
问题 I have a screen with say 500 width and 400 height, and I have a vector with a bunch of shapes. let say the vector has 2 different shapes for example. I want the object to randomly pop up from the bottom of the screen reach a certain ascent and then fall back down (similar to game fruit ninja, where the fruits are my shapes). In my main (view) I have a vector of shapes of which i instantiate the timers, add to array and place them in the buttom of the screen using the translate function. My