1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g2d.page;
14 import org.simantics.utils.page.PageDesc;
17 * @author Marko Luukkainen
19 public class DiagramDesc {
21 private final PageDesc pageDesc;
22 private final double gridSize;
23 private final boolean pageBordersVisible;
24 private final boolean marginsVisible;
27 private final boolean gridVisible;
28 private final boolean rulerVisible;
30 public DiagramDesc(PageDesc pageDesc, double gridSize, boolean pageBordersVisible, boolean marginsVisible, boolean gridVisible, boolean rulerVisible) {
31 this.pageDesc = pageDesc;
32 this.gridSize = gridSize;
33 this.pageBordersVisible = pageBordersVisible;
34 this.marginsVisible = marginsVisible;
35 this.gridVisible = gridVisible;
36 this.rulerVisible = rulerVisible;
39 public PageDesc getPageDesc() {
43 public double getGridSize() {
47 public boolean isPageBordersVisible() {
48 return pageBordersVisible;
51 public boolean isMarginsVisible() {
52 return marginsVisible;
55 public boolean isGridVisible() {
59 public boolean isRulerVisible() {
63 public DiagramDesc withPageDesc(PageDesc pageDesc) {
64 return new DiagramDesc(pageDesc, gridSize, pageBordersVisible, marginsVisible, gridVisible, rulerVisible);
68 public int hashCode() {
71 result = prime * result + ((pageDesc == null) ? 0 : pageDesc.hashCode());
73 temp = Double.doubleToLongBits(gridSize);
74 result = prime * result + (int) (temp ^ (temp >>> 32));
75 result = prime * result + (marginsVisible ? 1231 : 1237);
76 result = prime * result + (pageBordersVisible ? 1231 : 1237);
77 result = prime * result + (gridVisible ? 1231 : 1237);
78 result = prime * result + (rulerVisible ? 1231 : 1237);
83 public boolean equals(Object obj) {
88 if (getClass() != obj.getClass())
90 DiagramDesc other = (DiagramDesc) obj;
91 if (pageDesc == null) {
92 if (other.pageDesc != null)
94 } else if (!pageDesc.equals(other.pageDesc))
96 if (Double.doubleToLongBits(gridSize) != Double.doubleToLongBits(other.gridSize))
98 if (marginsVisible != other.marginsVisible)
100 if (pageBordersVisible != other.pageBordersVisible)
102 if (gridVisible != other.gridVisible)
104 if (rulerVisible != other.rulerVisible)
110 public String toString() {
111 return "[gridSize=" + gridSize + ", pageBordersVisible=" + pageBordersVisible + ", marginsVisible=" + marginsVisible + ", gridVisible=" + gridVisible + ", rulerVisible=" + rulerVisible + ", pageDesc=" + pageDesc + "]";