本文整理汇总了Scala中java.awt.Dimension类的典型用法代码示例。如果您正苦于以下问题:Scala Dimension类的具体用法?Scala Dimension怎么用?Scala Dimension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dimension类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: Tela
//设置package包名称以及导入依赖的类
package jerimum
import java.awt.{ Canvas, Dimension }
import br.edu.ifrn.potigol.Potigolutil.{ Inteiro, Texto }
import javax.swing.JFrame
class Tela(titulo: Texto, largura: Inteiro, altura: Inteiro) {
private[this] val dim = new Dimension(largura, altura)
val canvas = new Canvas() {
setPreferredSize(dim)
setMaximumSize(dim)
setMinimumSize(dim)
setFocusable(false)
}
val frame = new JFrame(titulo) {
setIconImage(Imagem("potigol.png").buffer)
setSize(dim)
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
setResizable(false)
setLocationRelativeTo(null)
setVisible(true)
add(canvas)
pack()
}
}
示例2: Drawer
//设置package包名称以及导入依赖的类
package io.sczyh30.tplot.interpreter
import swing.{MainFrame, SimpleSwingApplication}
import java.awt.Dimension
import io.sczyh30.tplot.lexer.Lexer
import io.sczyh30.tplot.parser.Parser
import scala.io.Source
object Drawer extends SimpleSwingApplication {
def top = new MainFrame { // TODO: enhance error handling
val src = Source.fromFile("src/test/resources/common.tp").getLines.mkString("\n")
val ast = new Parser().parse(new Lexer().go(src.toCharArray))
val data = ast.map(new Interpreter().interpret).get
title = "TrivialPlot Runtime"
contents = new DataPanel(data) {
preferredSize = new Dimension(1000, 1000)
}
}
}
示例3: GraphicMatrix
//设置package包名称以及导入依赖的类
package swayvil.langtonant.gui
import java.awt.{ Graphics2D, BasicStroke }
import java.awt.geom._ // Rectangle2D
import swayvil.langtonant.Matrix
import swayvil.langtonant.Square
import scala.swing.Panel
import java.awt.Color
import java.awt.Dimension
class GraphicMatrix(private var m: Matrix) extends Panel with GUI {
preferredSize = new Dimension(m.size * squareSize, m.size * squareSize)
override def paintComponent(g: Graphics2D) {
m.matrix.foreach { (row: Array[Square]) => row.foreach { (square: Square) => drawSquare(g, square.x, square.y) } }
}
override def repaint() {
super.repaint()
}
private def drawSquare(g: Graphics2D, x: Int, y: Int) {
var rec = new Rectangle2D.Double(squareSize * x, squareSize * y, squareSize, squareSize)
if (m.matrix(x)(y).isWhite)
g.setColor(white)
else
g.setColor(black)
if (m.matrix(x)(y).isAnt)
g.setColor(red)
g.fill(new Rectangle2D.Double(squareSize * x, squareSize * y, squareSize, squareSize))
g.setColor(black)
g.draw(new Rectangle2D.Double(squareSize * x, squareSize * y, squareSize, squareSize))
}
}
示例4: GraphicTurn
//设置package包名称以及导入依赖的类
package swayvil.langtonant.gui
import java.awt.{ Graphics2D }
import main.scala.swayvil.langtonant.Game
import scala.swing.Panel
import java.awt.Dimension
class GraphicTurn(var game: Game) extends Panel with GUI {
preferredSize = new Dimension(10, 10)
override def paintComponent(g: Graphics2D) {
// draw some text
g.setColor(black)
g.setFont(font)
g.drawString(game.turn.toString(), 10, 10)
}
override def repaint() {
super.repaint()
}
}
示例5: PremiseView
//设置package包名称以及导入依赖的类
package ui.premiseView
import java.awt.{Toolkit, BorderLayout, Dimension, Font}
import javax.swing._
class PremiseView(premise: String = "") extends JFrame {
private val premisePanel = new JPanel()
private var graphPanel: ResultPanel = null
config
configInput
start
private def start = {
val screenSize = Toolkit.getDefaultToolkit.getScreenSize
setSize(new Dimension(
(screenSize.getWidth * .60).toInt,
(screenSize.getHeight * .60).toInt))
setLocationRelativeTo(null)
setVisible(true)
}
private def config = {
setLayout(new BorderLayout())
add(premisePanel, BorderLayout.NORTH)
setIconImage(new ImageIcon("resources/icon.png").getImage)
setTitle(s"Premise View")
}
private def configInput = {
val premiseLabel = new JLabel()
val font = premiseLabel.getFont()
val boldFont = new Font(font.getFontName(), Font.BOLD, font.getSize())
premiseLabel.setFont(boldFont)
premiseLabel.setText(premise)
premisePanel.add(premiseLabel)
graphPanel = new ResultPanel(premise)
getContentPane.add(graphPanel)
getContentPane.repaint()
getContentPane.validate()
}
}
示例6: CheckerBackground
//设置package包名称以及导入依赖的类
package de.sciss.unlike
import java.awt.image.BufferedImage
import java.awt.{Dimension, Graphics2D, Paint, Rectangle, TexturePaint}
import scala.swing.Component
class CheckerBackground(sizeH: Int = 32)
extends Component
with Zoomable {
private[this] val pntBg: Paint = {
val img = new BufferedImage(sizeH << 1, sizeH << 1, BufferedImage.TYPE_INT_ARGB)
for (x <- 0 until img.getWidth) {
for (y <- 0 until img.getHeight) {
img.setRGB(x, y, if (((x / sizeH) ^ (y / sizeH)) == 0) 0xFF9F9F9F else 0xFF7F7F7F)
}
}
new TexturePaint(img, new Rectangle(0, 0, img.getWidth, img.getHeight))
}
opaque = false
def screenSizeUpdated(d: Dimension): Unit = {
preferredSize = d
peer.setSize(d)
revalidate()
}
override protected def paintComponent(g2: Graphics2D): Unit = {
val atOrig = g2.getTransform
g2.scale(_zoom, _zoom)
g2.translate(-clipLeftPx, -clipTopPx)
g2.setPaint(pntBg)
g2.fillRect(0, 0, virtualRect.width, virtualRect.height)
g2.setTransform(atOrig)
}
}
示例7: SlideShow
//设置package包名称以及导入依赖的类
package churchscreen.show
import org.apache.poi.hslf.usermodel.{SlideShow => ISlideShow}
import java.awt.Dimension
import java.io.{FileOutputStream, File}
object SlideShow
{
def apply(file : File, pageSize : Dimension = new Dimension(1024, 768)) : SlideShow =
{
val slideShow = new ISlideShow
slideShow.setPageSize(pageSize)
new SlideShow(show = slideShow, file = file)
}
}
class SlideShow(val show : ISlideShow, val file : File)
{
def create(options : ((Slide) => Unit)*) : Slide =
{
Slide(this, show.createSlide, options:_*)
}
def save() : Unit =
{
val out = new FileOutputStream(file)
show.write(out)
out.close()
}
}
示例8: Reading
//设置package包名称以及导入依赖的类
package churchscreen.show
import java.awt.{Rectangle, Dimension, Point}
import scala.io.StdIn.readLine
object Reading
{
def readPassage =
{
println("Enter passage:")
readLine()
}
def readPageNumber =
{
println("Enter page number:")
readLine()
}
def bibleReadingTitleAnchor = new Rectangle(new Point(51, 129), new Dimension(921, 260))
def bibleReadingTextAnchor = new Rectangle(new Point(51, 396), new Dimension(921, 320))
}
示例9: TestNext
//设置package包名称以及导入依赖的类
import java.awt.Dimension
import javax.swing.JFrame
import com.alee.laf.WebLookAndFeel
import com.sun.awt.AWTUtilities
import scala.swing.SimpleSwingApplication
object TestNext extends SimpleSwingApplication with AppMixin {
WebLookAndFeel.install()
def title = "Next"
override def startup(args: Array[String]): Unit = {
JFrame.setDefaultLookAndFeelDecorated(true)
// super.startup(args)
val t = top
AWTUtilities.setWindowOpaque ( t.peer, false )
// t.peer.setUndecorated(true)
t.peer.getRootPane.putClientProperty("styleId", "frame-decorated")
// if (t.size == new Dimension(0,0))
t.pack()
t.centerOnScreen()
t.visible = true
}
}
示例10: TestCurrent
//设置package包名称以及导入依赖的类
import java.awt.Dimension
import javax.swing.JFrame
import com.alee.laf.WebLookAndFeel
import scala.swing.SimpleSwingApplication
object TestCurrent extends SimpleSwingApplication with AppMixin {
WebLookAndFeel.install()
def title = "Current"
override def startup(args: Array[String]): Unit = {
JFrame.setDefaultLookAndFeelDecorated(true)
// super.startup(args)
val t = top
if (t.size == new Dimension(0,0)) t.pack()
t.peer.getRootPane.putClientProperty("styleId", "frame-decorated")
t.visible = true
}
}
示例11: SwingFrame
//设置package包名称以及导入依赖的类
package de.htwg.se.checkers.view.gui
import java.awt.{Dimension, Toolkit}
import akka.actor.ActorRef
import de.htwg.se.checkers.CheckersConfiguration
import de.htwg.se.checkers.controller.command.QuitGame
import de.htwg.se.checkers.model.GameState
import scala.swing._
import scala.swing.event.Key
class SwingFrame(controllerActor: ActorRef) extends Frame {
def exit: Unit = dispose()
title = "Checkers"
menuBar = buildMenuBar
implicit val bindingModule = CheckersConfiguration
val gamePanel = new InjectablePanel(controllerActor)(bindingModule).gamePanel
contents = new BorderPanel {
layout(gamePanel) = BorderPanel.Position.Center
}
peer.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE)
val dim = Toolkit.getDefaultToolkit.getScreenSize.height - 300
size = new Dimension(dim, dim)
visible = true
def update(state: GameState): Unit = {
gamePanel.update(state)
}
def buildMenuBar: MenuBar = {
new MenuBar {
contents += new Menu("Game") {
mnemonic = Key.G
contents += new MenuItem(Action("New") {
controllerActor ! println("restart game")
})
contents += new MenuItem(Action("Quit") {
controllerActor ! QuitGame
})
}
}
}
}
示例12: OpenProfileDialog
//设置package包名称以及导入依赖的类
package aug.gui
import java.awt.event.{ActionEvent, ActionListener}
import java.awt.{Dialog, Dimension, FlowLayout}
import javax.swing._
import aug.profile.ConfigManager
class OpenProfileDialog(mainWindow: MainWindow) extends
JDialog(mainWindow, "Open Profile", Dialog.ModalityType.DOCUMENT_MODAL) {
setSize(300, 180)
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
setLocationRelativeTo(mainWindow)
setLayout(new BoxLayout(getContentPane, BoxLayout.Y_AXIS))
private val profiles: Array[String] = ConfigManager.getUnactivedProfiles.toArray
val comboBox = new JComboBox[String](profiles)
val cancelButton = new JButton("cancel")
val openButton = new JButton("open")
val flowPanel = new JPanel()
flowPanel.setLayout(new FlowLayout())
flowPanel.add(cancelButton)
flowPanel.add(openButton)
if(profiles.isEmpty) openButton.setEnabled(false)
getRootPane.setDefaultButton(openButton)
getRootPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
comboBox.setMaximumSize(comboBox.getPreferredSize)
add(comboBox)
add(Box.createRigidArea(new Dimension(0, 10)))
add(flowPanel)
pack()
cancelButton.addActionListener(new ActionListener {
override def actionPerformed(e: ActionEvent): Unit = setVisible(false)
})
openButton.addActionListener(new ActionListener {
override def actionPerformed(e: ActionEvent): Unit = {
ConfigManager.activateProfile(comboBox.getSelectedItem.toString, mainWindow)
setVisible(false)
}
})
setVisible(true)
}