Skip to content

Commit

Permalink
Rewrites width/height vars ad a Dimension obj.
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkryst committed Sep 28, 2017
1 parent 5dc9667 commit b3af91d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/com/valkryst/VTerminal/font/Font.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.NonNull;
import lombok.ToString;

import java.awt.Dimension;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
Expand All @@ -19,10 +20,8 @@ public class Font {
*/
private final HashMap<Character, BufferedImage> characterImages;

/** The width of the font. */
@Getter private final int width;
/** The height of the font. */
@Getter private final int height;
/** The width/height of the font. */
@Getter private final Dimension dimensions;

/**
* Constructs a new Font.
Expand All @@ -42,8 +41,9 @@ public class Font {
public Font(final @NonNull HashMap<Character, BufferedImage> characterImages, final int scale) throws IOException {
this.characterImages = characterImages;

width = characterImages.get('X').getWidth() * scale;
height = characterImages.get('X').getHeight() * scale;
final int width = characterImages.get('X').getWidth() * scale;
final int height = characterImages.get('X').getHeight() * scale;
dimensions = new Dimension(width, height);

if (scale > 0) {
final AffineTransform tx = AffineTransform.getScaleInstance(scale, scale);
Expand Down Expand Up @@ -83,4 +83,12 @@ public boolean isCharacterSupported(final char character) {
public BufferedImage getCharacterImage(final char character) {
return characterImages.get(character);
}

public int getWidth() {
return dimensions.width;
}

public int getHeight() {
return dimensions.height;
}
}

0 comments on commit b3af91d

Please sign in to comment.