graphics2d

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

Java: Rotating Images

守給你的承諾、 提交于 2019-11-26 02:59:04
问题 I need to be able to rotate images individually(in java). The only thing I have found so far is g2d.drawImage(image, affinetransform, ImageObserver ). Unfortunately, I need to draw the image at a specific point, and there is no method with an argument that 1.rotates the image separately and 2. allows me to set the x and y. any help is appreciated 回答1: This is how you can do it. This code assumes the existance of a buffered image called 'image' (like your comment says) // The required drawing

Stretch a JLabel text

久未见 提交于 2019-11-26 02:15:06
问题 Is there a way to make a JLabel\'s text stretch to 100% height? I need the text to update when the component\'s size changes as well. I saw some solution that could work; It involved calculating and setting the font size so it appears the right height. I would have also have to add listeners for when the height changed to make it respond and I do not know exactly where I should do that. I am hoping for a better solution with layout managers, but couldn\'t find anything. Any ideas? 回答1: In the

Swing HTML drawString

点点圈 提交于 2019-11-25 23:50:57
问题 I\'m trying to create some special component for a specific purpose, on that component I need to draw a HTML string, here\'s a sample code: public class MyComponent extends JComponent{ public MyComponent(){ super(); } protected void paintComponent(Graphics g){ //some drawing operations... g.drawString(\"<html><u>text to render</u></html>\",10,10); } } Unfortunately the drawString method seems to be not recognizing the HTML format, it foolishly draws the string just as it is. Is there any way

Passing current Date

做~自己de王妃 提交于 2019-11-25 23:32:02
问题 Seems like as not possible to fix Graphics2D lack in code, there I must to set fix size for animations, otherwise some Start outside Rectangle 490 x 490 freeze or shaking on the screen my SSCCE import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Random; import java.util.Vector; import java.util.regex.Pattern; import javax.swing.*; import javax.swing.table.*; public class

Using Graphics2D to overlay text on a BufferedImage and return a BufferedImage

烈酒焚心 提交于 2019-11-25 23:25:24
问题 I have checked similarly named questions, but they don\'t answer this use case. Basically, I was to overlay some text (text) at a given coordinate (x,y) I have the below function in a package; protected BufferedImage Process2(BufferedImage image){ Graphics2D gO = image.createGraphics(); gO.setColor(Color.red); gO.setFont(new Font( \"SansSerif\", Font.BOLD, 12 )); gO.drawString(this.text, this.x, this.y); System.err.println(this.text+this.x+this.y); return image; } I feel like im missing