Had fight with maven. It decided to block HTTP repositories.
[meviz.git] / src / main / java / eu / svjatoslav / meviz / htmlindexer / metadata / Dimension.java
1 /*
2  * Meviz - Various tools collection to work with multimedia. Author: Svjatoslav Agejenko.
3  * This project is released under Creative Commons Zero (CC0) license.
4  */
5
6
7 package eu.svjatoslav.meviz.htmlindexer.metadata;
8
9 import java.io.Serializable;
10
11 /**
12  * Corresponds to single image dimensions.
13  */
14
15 public class Dimension implements Serializable, Comparable<Dimension> {
16
17     private static final long serialVersionUID = -1039288266937331829L;
18
19     public int width;
20     public int height;
21
22     private Dimension() {
23         width = 0;
24         height = 0;
25     }
26
27     public Dimension(final Dimension origial) {
28         width = origial.width;
29         height = origial.height;
30     }
31
32     public Dimension(final int width, final int height) {
33         this.width = width;
34         this.height = height;
35     }
36
37     @Override
38     public int compareTo(final Dimension anotherDimension) {
39         if (width < anotherDimension.width)
40             return -1;
41         if (width > anotherDimension.width)
42             return 1;
43
44         if (height < anotherDimension.height)
45             return -1;
46         if (height > anotherDimension.height)
47             return 1;
48
49         return 0;
50     }
51
52     public boolean equals(final Dimension anotherDimension) {
53         return compareTo(anotherDimension) == 0;
54     }
55
56     public int getArea() {
57         return width * height;
58     }
59
60     public java.awt.Dimension getAwtDimension() {
61         return new java.awt.Dimension(width, height);
62     }
63
64     public Dimension getScaled(final double multiplicationFactor) {
65         final Dimension result = new Dimension();
66
67         result.width = (int) ((width) * multiplicationFactor);
68         result.height = (int) ((height) * multiplicationFactor);
69
70         return result;
71     }
72
73     @Override
74     public String toString() {
75         return "Dimension [width=" + width + ", height=" + height + "]";
76     }
77
78 }