-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Improve paper size handling (for printing)
- Allow setting canvas size.
- Loading branch information
Showing
5 changed files
with
85 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.kogics.kojo.lite | ||
|
||
trait PaperSize { | ||
def name: String | ||
def width: Double | ||
def height: Double | ||
} | ||
|
||
case object A4 extends PaperSize { | ||
val name = "A4" | ||
val width = 8.268 | ||
val height = 11.693 | ||
} | ||
|
||
case object A4Landscape extends PaperSize { | ||
val name = "A4 Landscape" | ||
val width = 11.693 | ||
val height = 8.268 | ||
} | ||
|
||
object PaperSize { | ||
def fromString(s: String): Option[PaperSize] = { | ||
if (s == null) { | ||
None | ||
} | ||
else { | ||
s.toLowerCase.trim match { | ||
case "a4" => Some(A4) | ||
case "a4 landscape" => Some(A4Landscape) | ||
case _ => None | ||
} | ||
} | ||
} | ||
|
||
def allSizes: Seq[String] = { | ||
List(A4, A4Landscape).map(_.name) | ||
} | ||
} |