1 package org.coolreader.crengine; 2 3 public class PositionProperties { 4 public int x; 5 public int y; 6 public int fullHeight; 7 public int pageHeight; 8 public int pageWidth; 9 public int pageNumber; 10 public int pageCount; 11 public int pageMode; // 1, 2 for page mode, 0 for scroll mode 12 public int charCount; 13 public int imageCount; 14 public String pageText; 15 16 PositionProperties(PositionProperties v)17 public PositionProperties(PositionProperties v) { 18 x = v.x; 19 y = v.y; 20 fullHeight = v.fullHeight; 21 pageHeight = v.pageHeight; 22 pageWidth = v.pageWidth; 23 pageNumber = v.pageNumber; 24 pageCount = v.pageCount; 25 pageMode = v.pageMode; 26 charCount = v.charCount; 27 imageCount = v.imageCount; 28 } 29 PositionProperties()30 public PositionProperties() { 31 32 } 33 getPercent()34 public int getPercent() { 35 if (fullHeight - pageHeight <= 0) 36 return 0; 37 int p = 10000 * y / (fullHeight - pageHeight); 38 if (p < 0) 39 p = 0; 40 if (p > 10000) 41 p = 10000; 42 return p; 43 } 44 45 @Override clone()46 public Object clone() throws CloneNotSupportedException { 47 return super.clone(); 48 } 49 canMoveToNextPage()50 public boolean canMoveToNextPage() { 51 if (pageMode == 0) { 52 return fullHeight > pageHeight && y < fullHeight - pageHeight; 53 } 54 return pageNumber < pageCount - pageMode; 55 } 56 57 @Override toString()58 public String toString() { 59 return "PositionProperties [pageMode=" + pageMode + ", pageNumber=" 60 + pageNumber + ", pageCount=" + pageCount + ", x=" + x + ", y=" 61 + y + ", pageHeight=" + pageHeight + ", pageWidth=" + pageWidth 62 + ", fullHeight=" + fullHeight + "]"; 63 } 64 @Override hashCode()65 public int hashCode() { 66 final int prime = 31; 67 int result = 1; 68 result = prime * result + fullHeight; 69 result = prime * result + pageCount; 70 result = prime * result + pageHeight; 71 result = prime * result + pageMode; 72 result = prime * result + pageNumber; 73 result = prime * result + pageWidth; 74 result = prime * result + x; 75 result = prime * result + y; 76 return result; 77 } 78 @Override equals(Object obj)79 public boolean equals(Object obj) { 80 if (this == obj) 81 return true; 82 if (obj == null) 83 return false; 84 if (getClass() != obj.getClass()) 85 return false; 86 PositionProperties other = (PositionProperties) obj; 87 if (fullHeight != other.fullHeight) 88 return false; 89 if (pageCount != other.pageCount) 90 return false; 91 if (pageHeight != other.pageHeight) 92 return false; 93 if (pageMode != other.pageMode) 94 return false; 95 if (pageNumber != other.pageNumber) 96 return false; 97 if (pageWidth != other.pageWidth) 98 return false; 99 if (x != other.x) 100 return false; 101 if (y != other.y) 102 return false; 103 return true; 104 } 105 106 107 } 108