本文整理汇总了Scala中javax.swing.ImageIcon类的典型用法代码示例。如果您正苦于以下问题:Scala ImageIcon类的具体用法?Scala ImageIcon怎么用?Scala ImageIcon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ImageIcon类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: MNISTVisualizer
//设置package包名称以及导入依赖的类
package org.dl4scala.examples.feedforward.anomalydetection
import java.awt.{GridLayout, Image}
import java.awt.image.BufferedImage
import javax.swing.{ImageIcon, JFrame, JLabel, JPanel}
import org.nd4j.linalg.api.ndarray.INDArray
import scala.collection.mutable.ArrayBuffer
class MNISTVisualizer(imageScale: Double, digits: ArrayBuffer[INDArray], title: String, gridWidth: Int) {
def this(imageScale: Double, digits: ArrayBuffer[INDArray], title: String) = {
this(imageScale, digits, title, 5)
}
def visualize(): Unit = {
val frame = new JFrame
frame.setTitle(title)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
val panel = new JPanel
panel.setLayout(new GridLayout(0, gridWidth))
val list = getComponents
for (image <- list) {
panel.add(image)
}
frame.add(panel)
frame.setVisible(true)
frame.pack()
}
def getComponents: ArrayBuffer[JLabel] = {
val images = new ArrayBuffer[JLabel]()
for (arr <- digits) {
val bi = new BufferedImage(28, 28, BufferedImage.TYPE_BYTE_GRAY)
for(i <- 0 until 784) {
bi.getRaster.setSample(i % 28, i / 28, 0, (255 * arr.getDouble(i)).asInstanceOf[Int])
}
val orig = new ImageIcon(bi)
val imageScaled = orig.getImage.getScaledInstance((imageScale * 28).asInstanceOf[Int],
(imageScale * 28).asInstanceOf[Int], Image.SCALE_REPLICATE)
val scaled = new ImageIcon(imageScaled)
images.append(new JLabel(scaled))
}
images
}
}
开发者ID:endymecy,项目名称:dl4scala,代码行数:48,代码来源:MNISTVisualizer.scala
示例2: TrayIcon
//设置package包名称以及导入依赖的类
package se.gigurra.dcs.remote
import java.awt
import java.awt._
import java.awt.event.{ActionEvent, ActionListener}
import javax.swing.ImageIcon
import se.gigurra.serviceutils.twitter.logging.Logging
case class TrayIcon(exitCallback: () => Unit) {
val base = createImage("tray_icons/base.png", "base")
val popup = new PopupMenu()
val trayIcon = new awt.TrayIcon(base)
val tray = SystemTray.getSystemTray
val exitItem = new MenuItem("Exit")
exitItem.addActionListener(new ActionListener { override def actionPerformed(e: ActionEvent): Unit = exitCallback() })
trayIcon.setToolTip("DCS-Remote REST Proxy")
popup.add(exitItem)
trayIcon.setPopupMenu(popup)
tray.add(trayIcon)
def createImage(path: String, description: String): Image = {
val imageURL = getClass.getClassLoader.getResource(path)
if (imageURL == null) {
throw new RuntimeException("Resource not found: " + path)
} else {
new ImageIcon(imageURL, description).getImage
}
}
}
object TrayIcon extends Logging{
def setup(): Option[TrayIcon] = {
SystemTray.isSupported match {
case true =>
logger.info("Tray icon supported! Setting up tray icon..")
Some(TrayIcon(() => System.exit(0)))
case false =>
logger.info("Tray icon not supported!")
None
}
}
}
开发者ID:GiGurra,项目名称:dcs-remote2,代码行数:48,代码来源:TrayIcon.scala
示例3: CharInfo
//设置package包名称以及导入依赖的类
package de.htwg.se.zombiezite.aview.gui
import de.htwg.se.zombiezite.model.Character
import de.htwg.se.zombiezite.controller._
import scala.swing._
import javax.swing.ImageIcon
class CharInfo(c: Character, iconPath: String, mode: String) extends Frame {
val grid = new GridPanel(10, 1) {
if (mode == "Zombie") {
contents += new Label("^*^*^*^*" + c.name + "^*^*^*^*") {
font = new Font("Arial", java.awt.Font.HANGING_BASELINE, 20)
}
} else if (mode == "Player") {
contents += new Label("*********" + c.name + "*********") {
font = new Font("Arial", java.awt.Font.HANGING_BASELINE, 20)
}
}
contents += new Label {
icon = new ImageIcon(iconPath)
}
contents += new Label("Lifepoints: *" + c.lifePoints.toString() + "*"){
font = new Font("Arial", java.awt.Font.TRUETYPE_FONT, 20)
}
contents += new Label("Schaden: <" + (c.strength + c.equippedWeapon.strength).toString() + "> Reichweite : <" + (c.range + c.equippedWeapon.range).toString() + ">"){
font = new Font("Arial", java.awt.Font.TRUETYPE_FONT, 20)
}
contents += Button("Ok") { dispose() }
}
contents_=(grid)
visible = true
}
开发者ID:DOSlp24,项目名称:ZombieZite,代码行数:34,代码来源:CharInfo.scala
示例4: MainWindow
//设置package包名称以及导入依赖的类
package fi.kajstrom.efpscala.E49
import java.net.URL
import javax.swing.ImageIcon
import scala.swing._
class MainWindow(imageService: ImageService) extends MainFrame{
title = "Photo Search"
preferredSize = new Dimension(640, 480)
contents = new BoxPanel(Orientation.Horizontal) {
val text = new TextField()
text.maximumSize = new Dimension(150, 30)
contents += text
contents += Button("Search") {
val images = imageService.findWithTag(text.text)
println(images)
showImages(images)
}
}
def showImages(images: List[Image]): Unit = {
import javax.imageio.ImageIO
import java.awt.image.BufferedImage
contents = new BoxPanel(Orientation.Vertical) {
images.take(1).foreach((image: Image) => {
val url = new URL(images.head.url)
val img: BufferedImage = ImageIO.read(url)
val label = new Label {
icon = new ImageIcon(img)
}
contents += label
})
}
}
}
开发者ID:kajstrom,项目名称:EFP-Scala,代码行数:41,代码来源:MainWindow.scala
示例5: NormalCard
//设置package包名称以及导入依赖的类
package de.htwg.se.phase10.model.impl
import javax.swing.ImageIcon
import de.htwg.se.phase10.model.ICard
trait Card extends ICard
case class NormalCard(color: Colors.Value, cardtype: Int) extends Card {
var icon:ImageIcon = null
override def getRank = this.cardtype
override def getColor = this.color.toString()
override def setIcon() {
icon = new ImageIcon(new ImageIcon("./img/" + getColor + getRank +".jpg").getImage().getScaledInstance(100,120, java.awt.Image.SCALE_SMOOTH))
}
override def getIcon = icon
override def toString: String = getColor +" "+getRank.toString()
}
case class SpecialCard(typeCard: CardType.Value) extends Card {
var icon:ImageIcon = null
override def getRank = this.typeCard
override def getColor = "Blau"
override def setIcon() {
icon = new ImageIcon(new ImageIcon("./img/" + getColor + getRank +".jpg").getImage().getScaledInstance(100,120, java.awt.Image.SCALE_SMOOTH))
}
override def getIcon = icon
override def toString: String = getColor+" "+getRank.toString()
}
object Colors extends Enumeration {
val Red, Green, Yellow, Purple = Value
}
object CardType extends Enumeration {
val Joker, Break = Value
}
开发者ID:JaromirCharles,项目名称:SE-Phase-10,代码行数:39,代码来源:Card.scala
示例6: DeckStack
//设置package包名称以及导入依赖的类
package de.htwg.se.phase10.aview.gui
import swing._
import swing.event._
import de.htwg.se.phase10.controller.IController
import java.awt.Color
import javax.swing.ImageIcon
class DeckStack (gui:createGameField, controller:IController) extends Frame {
val color = new Color(0x00592D)
def deckStack = new FlowPanel {
contents += deck
contents += stack
background_=(color)
}
val deck = new Button {
this.preferredSize_=(new Dimension(100,120))
this.borderPainted_=(true)
this.icon_=(new ImageIcon(new ImageIcon("./img/Phase10Deck.png").getImage().getScaledInstance(100,120, java.awt.Image.SCALE_SMOOTH)))
}
val stack = new Button {
preferredSize_=(new Dimension(100,120))
borderPainted_=(true)
icon_=(controller.getStackCard().getIcon)
opaque_=(false)
contentAreaFilled_=(false)
}
listenTo(deck,stack)
reactions += {
case ButtonClicked(`stack`) if(!controller.getPullCard()) => controller.getCardStack();gui.handCards.updateHand();gui.deckStack.updateStack();gui.player.updateButtons()
case ButtonClicked(`stack`) if(controller.getPullCard()) => gui.infoFeld.turnPhase.text_=("You Pulled a card already!")
case ButtonClicked(`stack`) if(controller.getStackSize() == 0) => gui.infoFeld.turnPhase.text_=("Stack is empty, sou you pulled a card from the deck!")
case ButtonClicked(`deck`) if(!controller.getPullCard()) => controller.getCardDeck();gui.handCards.updateHand();gui.player.updateButtons()
case ButtonClicked(`deck`) if(controller.getPullCard()) => gui.infoFeld.turnPhase.text_=("You Pulled a card already!")
}
def updateStack() {
if (controller.getStackSize() == 0) {
stack.borderPainted_=(true)
stack.icon_=(null)
stack.opaque_=(false)
stack.contentAreaFilled_=(false)
} else {
stack.icon_=(controller.getStackCard().getIcon)
}
}
}
开发者ID:JaromirCharles,项目名称:SE-Phase-10,代码行数:52,代码来源:DeckStack.scala
示例7: Phasen
//设置package包名称以及导入依赖的类
package de.htwg.se.phase10.aview.gui
import swing._
import javax.swing.ImageIcon
import de.htwg.se.phase10.controller.IController
import scala.swing.event.ButtonClicked
class Phasen(gui:createGameField,name:String,controller:IController) extends Frame {
val color = new Color(0x00592D)
def phasenCard = new FlowPanel() {
contents += card
background = color
}
val card = new Button {
this.preferredSize_=(new Dimension(100,120))
this.icon_=(new ImageIcon(new ImageIcon("./img/phasen.jpg").getImage().getScaledInstance(100,120, java.awt.Image.SCALE_SMOOTH)))
this.borderPainted_=(true)
}
listenTo(card)
reactions += {
case ButtonClicked(`card`) if (!gui.willMove && !controller.getMove() && !gui.playerMenu) => gui.willMove = true;gui.move.updateMove; gui.move.top.visible_=(true)
case ButtonClicked(`card`) if(gui.willMove || gui.playerMenu) =>
case ButtonClicked(`card`) => gui.infoFeld.turnPhase.text_=("You did this phase already!")
}
}
开发者ID:JaromirCharles,项目名称:SE-Phase-10,代码行数:30,代码来源:Phasen.scala
示例8: Window
//设置package包名称以及导入依赖的类
import java.awt.BorderLayout
import java.awt.BorderLayout.{CENTER, PAGE_END, PAGE_START}
import javax.swing.JFrame.EXIT_ON_CLOSE
import javax.swing.{JFrame, ImageIcon, JLabel, JPanel, BorderFactory}
class Window extends JFrame with StatusChangeCallback {
private val instructions = "<html><br>'m' - Exit<br>'z' - Start<br>'x' - Stop<br>'p' - Play/Pause</html>"
private val icon = new ImageIcon("src/main/resources/mch.png")
private val lblLogo = new JLabel(icon)
private val lblStatus = new JLabel("Waiting")
private val panel = new JPanel()
private val lblInstructions = new JLabel(instructions)
setDefaultCloseOperation(EXIT_ON_CLOSE)
setTitle("MyClickHolder")
setResizable(false)
setIconImage(icon.getImage)
panel.setLayout(new BorderLayout())
panel.setBorder(BorderFactory.createEmptyBorder(50, 50, 50, 50))
panel.add(lblLogo, PAGE_START)
panel.add(lblStatus, CENTER)
panel.add(lblInstructions, PAGE_END)
add(panel)
pack()
setVisible(true)
override def statusChanged(status: String): Unit = {
lblStatus.setText(status)
}
override def engineExit(): Unit = {
System.exit(0)
}
}
开发者ID:gabrsar,项目名称:MyClickHolder,代码行数:40,代码来源:Window.scala
示例9: ImageIcons
//设置package包名称以及导入依赖的类
package gui
import java.net.URL
import javax.swing.ImageIcon
import enums.ConnectionMode
object ImageIcons {
var usbIcon: ImageIcon = new ImageIcon(getImagePath(ConnectionMode.USB))
var wifiIcon: ImageIcon = new ImageIcon(getImagePath(ConnectionMode.WIFI))
private def getImagePath(mode: ConnectionMode): URL = {
if (mode == ConnectionMode.USB) {
this.getClass.getResource("res/img/usb.png")
}
else if (mode == ConnectionMode.WIFI) {
this.getClass.getResource("res/img/wifi.png")
} else {
new URL("")
}
}
}
开发者ID:murizaky,项目名称:dasdasd,代码行数:23,代码来源:ImageIcons.scala
示例10: Rotate
//设置package包名称以及导入依赖的类
package MicrowaveOvenSPL.oven
import scala.swing._
import java.awt.Graphics2D._
import javax.swing.ImageIcon
object Rotate extends SimpleSwingApplication {
val imgTurntable = new Label {
text = "I am a label"
icon = new ImageIcon("MicrowaveOvenSPL.MicrowaveOvenSPL.microwavegui.oven.images/Turntable.jpg")
preferredSize = new Dimension(100, 100)
}
def top = new MainFrame {
contents = imgTurntable
}
val p = new Panel {
override def paint(g: Graphics2D) {
//drawRotate(g, 50, 50, 45, "H")
//g.drawImage(imgTurntable, 0, 0, this)
}
preferredSize = new Dimension(200, 200)
}
def drawRotate(g2d: Graphics2D, x: Double, y: Double, angle: Int, text: String) {
for (i <- 1 to 8) {
g2d.translate(x, y)
g2d.rotate(Math.toRadians(angle * i))
g2d.drawString(text, 0, 0);
g2d.rotate(-Math.toRadians(angle * i));
g2d.translate(-x, -y);
}
}
}
开发者ID:ternava,项目名称:Variability-CChecking,代码行数:39,代码来源:Rotate.scala
示例11: Icons
//设置package包名称以及导入依赖的类
package acumen.ui
import java.net.URL
import javax.swing.ImageIcon
import javax.swing.Icon
object Icons {
private val homeUrl = this.getClass.getResource("icons/home.png")
private val zoomInUrl = this.getClass.getResource("icons/zoomin.png")
private val zoomOUtUrl = this.getClass.getResource("icons/zoomout.png")
private val undoUrl = this.getClass.getResource("icons/undo.png")
private val saveUrl = this.getClass.getResource("icons/save.png")
private val replayUrl = this.getClass.getResource("icons/replay.png")
private val fasterUrl = this.getClass.getResource("icons/faster.png")
private val slowerUrl = this.getClass.getResource("icons/slower.png")
private val default = new ImageIcon()
private def get(u: URL) : Icon = {
if (u == null) default
else new ImageIcon(u)
}
lazy val record = get(recordUrl)
lazy val play = get(playUrl)
lazy val step = get(stepUrl)
lazy val pause = get(pauseUrl)
lazy val stop = get(stopUrl)
lazy val home = get(homeUrl)
lazy val undo = get(undoUrl)
lazy val save = get(saveUrl)
lazy val zoomIn = get(zoomInUrl)
lazy val zoomOut = get(zoomOUtUrl)
lazy val replay = get(replayUrl)
lazy val faster = get(fasterUrl)
lazy val slower = get(slowerUrl)
lazy val defaultView = get(defaultViewUrl)
lazy val frontView = get(frontViewUrl)
lazy val topView = get(topViewUrl)
lazy val rightView = get(rightViewUrl)
}
开发者ID:janduracz,项目名称:acumen-dev,代码行数:44,代码来源:Icons.scala
示例12: PanelBanner
//设置package包名称以及导入依赖的类
package uniandes.cupi2.dogBook.interfaz
import scala.swing._
import scala.swing.BorderPanel.Position._
import javax.swing.ImageIcon
class PanelBanner extends BorderPanel{
val label = new Label {
verticalTextPosition = Alignment.Bottom
horizontalTextPosition = Alignment.Center
horizontalAlignment = Alignment.Center
border = Swing.EmptyBorder(0)
icon = new ImageIcon("./data/imagenes/titulo.jpg")
}
layout(label) = Center
}
开发者ID:ncardozo,项目名称:scalakids,代码行数:19,代码来源:PanelBanner.scala
示例13: MoleculeList
//设置package包名称以及导入依赖的类
package widgets
import java.awt.Color
import java.awt.image.BufferedImage
import javax.swing.ImageIcon
import application.{RMapViewer, ScratchingBrowser}
import graph.Vertex
import scala.swing._
import scala.swing.event.{MouseClicked, ListSelectionChanged}
class MoleculeList extends ScrollPane {
def rmap = RMapViewer.rmap
val listView: ListView[ImageIcon] = new ListView[ImageIcon]() {
selection.intervalMode = ListView.IntervalMode.MultiInterval
object Command extends Publisher {
reactions += {
case ListSelectionChanged(source, range, live) =>
rmap.setSelections(source.selection.indices.toList.map(listVertices(_)))
}
listenTo(mouse.clicks)
reactions += {
case e: MouseClicked =>
if (e.peer.getButton() > 1 && listView.selection.indices.nonEmpty) {
RMapViewer.mapPanel.popupMenu(listVertices(listView.selection.indices.head)).show(ScratchingBrowser.moleculeList.peer, e.point.x, e.point.y)
}
}
}
Command.listenTo(selection)
}
def width = size.width
var listVertices: List[Vertex] = List()
def update(vertices: List[Vertex]) = {
listVertices = vertices
listView.listData = vertices.map((vertex: Vertex) => {
val image = new BufferedImage(width - 30, 64, BufferedImage.TYPE_INT_BGR)
val graphics = image.createGraphics()
graphics.setPaint(Color.white)
graphics.fillRect(0, 0, image.getWidth, image.getHeight)
val thumbnail = vertex.image
graphics.drawImage(thumbnail, 0, 0, 64, 64, 0, 0, thumbnail.getWidth(), thumbnail.getHeight(), ScratchingBrowser.peer)
val fontMetrics = graphics.getFontMetrics()
graphics.setPaint(Color.BLACK)
graphics.drawString(vertex.label, 70, (64 - fontMetrics.getAscent) / 2)
new ImageIcon(image)
})
self repaint()
}
viewportView = listView
preferredSize = new Dimension(200, 500)
}
开发者ID:ReactionMap,项目名称:RMapViewerS,代码行数:60,代码来源:MoleculeList.scala
注:本文中的javax.swing.ImageIcon类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论