- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 slider 接受输入并在颜色调整的帮助下在 ImageView 上应用效果
public void adjustBrightness() {
colorAdjust.setBrightness(brightnessSlider.getValue());
imageView.setEffect(colorAdjust);
addDrawOperation(imageView.getImage());
}
public void adjustSaturation() {
colorAdjust.setSaturation(saturationSlider.getValue());
imageView.setEffect(colorAdjust);
addDrawOperation(imageView.getImage());
}
public void adjustContrast() {
colorAdjust.setContrast(contrastSlider.getValue());
imageView.setEffect(colorAdjust);
addDrawOperation(imageView.getImage());
}
public void adjustHue() {
colorAdjust.setHue(hueSlider.getValue());
imageView.setEffect(colorAdjust);
addDrawOperation(imageView.getImage());
}
最佳答案
据我所知,没有简单的内置机制可以做你想做的事情。为了撤消和重做应用的颜色调整,您需要将颜色调整的副本保存到 ArrayDeque 之类的文件中。要撤消和重做,您可以在撤消和重做双端队列之间移动调整并应用调整。
一个简单的保存函数会将当前调整保存到撤消双端队列:
private Deque<ColorAdjustment> undos = new ArrayDeque<>();
private Deque<ColorAdjustment> redos = new ArrayDeque<>();
public void saveColorAdjustment(ColorAdjust save) {
ColorAdjust copy = new ColorAdjust(save.getHue(), save.getSaturation(), save.getBrightness(), save.getContrast());
undos.addLast(copy)
// clear any redos since we added a new undo
redos.clear()
}
然后在每个调整函数中,更改 colorAdjust 后调用保存,以便最近的更改可用于重做:
public void adjustHue() {
colorAdjust.setHue(hueSlider.getValue());
saveColorAdjustment(colorAdjust);
imageView.setEffect(colorAdjust);
addDrawOperation(imageView.getImage());
}
然后撤消和重做将在双端队列之间移动调整并根据需要设置颜色调整。
public void undoColorAdjustment() {
if (undos.size() > 0) {
// move last undo (which is current applied adjustment) to redo
redos.addFirst(undos.removeLast())
// apply last color effect
imageView.setEffect(undos.getLast());
addDrawOperation(imageView.getImage());
}
}
public void redoColorAdjustment() {
if (redos.size() > 0 ) {
// move first redo to undos
undos.addLast(redos.removeFirst());
// apply last color effect
imageView.setEffect(undos.getLast());
addDrawOperation(imageView.getImage());
}
}
这应该给你基本的想法。当然,您需要处理撤消为空时的情况,以不应用颜色调整或从 ImageView 中删除效果。
这只是一种方法。 Swing 提供了一个 UndoManager,您可以在其中为要应用的每个操作(例如 UndoColorAdjustment())创建一个类,并处理管理撤消和重做列表。您可以使用该 UndoManager 或创建自己的 UndoManager。否则,我这里有一个简单直接的方法。
关于java - 有没有办法在 imageView 上实现重做和撤消,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62150859/
示例:我在 C 列中有一个公式,它是 A 和 B 列中值的函数。当我更改 A 或 B 中的值并按 Enter 键时,C 中的值会自动更新。但是,当我 Ctrl-Z 时,C 列中的值不会自动恢复到我更改
我使用 Eclipse 进行几乎所有语言的编程。我也喜欢用于快速编辑的 vim 快捷方式,所以我安装了 vrapper。问题是当我写了很多代码,我只想撤消一些小东西。它撤消了很多代码块,而不是 2 或
假设我们无意中将命名分支( ABC ) merge 到我们的 default 中。分支。 hg rollback不是一个选择,因为从那以后有几次提交。 有没有办法撤销这个? 最佳答案 您将需要 Mq
有什么办法可以实现这一点吗?我正在使用一个分页插件,它读取 ul 中的 li 数量,并确定要吐出的编号链接的数量。 最佳答案 您可能想使用 .hide() 并检查 li 是否可见。 这可以通过以下方式
我需要能够检测是否触发了“撤销”,以及它是否对我的 RichTextBox 的内容产生了影响。 当我在 RichTextBox 中键入内容,然后按 Ctrl+Z 时,windows 似乎会为我处理撤消
我的每个 php 页面的顶部都有以下代码: foreach ($_POST as $key => $value) { if (!is_array($value)) {
我正在为一个类的项目工作,我们应该在该类中实现文本编辑器的基本功能,包括撤消和重做。我目前的撤消/重做功能正常工作,唯一的问题是,我在尝试从 Command 中释放内存时遇到 valgrind 错误。
假设我有以下两个变量: bob1 = u'bob\xf0\xa4\xad\xa2' bob2 = 'bob\xf0\xa4\xad\xa2' 如何让 bob1 的值成为 bob2 的值?也就是说,我如
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 1 年前。 社区在 1 年前 审查了是否重
我已经成功地实现了 touchesMoved 并且它正在正确地绘制线条,现在我在实现删除方法时遇到了问题,请在我缺少的地方帮助我。 - (void)touchesMoved:(NSSet *)touc
我使用的是 Visual Studio 2015。TFS 的版本是 2012(版本 11.0.51106.1)。有没有办法撤销 unshelve,其他用户的 shelfset,有 unshelve 命
我正在使用 intelliJ 在功能分支上工作,我想将我的团队在 master 上所做的更改集成到我的分支中,但我搞砸了。 我检查了 master,从 Git pop 窗口中我选择了功能分支并选择了“
我的情况:我克隆了一个存储库(内核的源文件)。然后检查了一个分支,并构建了内核。二进制文件已存储在工作树的子目录中。现在,我想放弃所有本地更改,包括构建的二进制文件,并恢复到克隆存储库的不同分支。 我
我正在使用 SourceTree,我在“工作副本更改”部分下有一些修改过的文件,这些文件正在被跟踪,如图中的黄色图标所示。但我放弃了这些变化。现在如何恢复这些更改? 最佳答案 如果项目未暂存(在顶部
撤消特定提交的最简单方法是: 不在头部或头部 已推送到远程。 因为如果不是最新的提交, git reset HEAD 没用。并且因为它已经被推送到远程, git rebase -i 和 git reb
我有一个 Pdf 文件,每页包含几张幻灯片,包括文本(不仅是图像)。 该 pdf 可能是使用 pdfnup 创建的。 我可以恢复 pdfnup 操作,以便每张幻灯片都显示在一页上吗? 最佳答案 据我所
我正在进行合并。合并后,我提交所有文件而没有冲突。然后我解析单个文件并提交它们。如果我犯了一个错误,我该如何重做解析(即使我还没有提交解析文件)? 与预期相反,我无法还原文件。合并后恢复到任何步骤时,
当之后进行了 17 次提交时,如何撤消不应该进行的提交? 背景:我团队的一个同事单独工作了一个月,现在是时候将他们的分支 merge 到 master 上了。但是,其中一个提交包含一个太大的文件,无法
我正在尝试使用Command Pattern在我的应用程序中实现撤消/重做功能。我遇到了一个问题。 为了说明这一点,让我们假设您可以使用我的应用程序2D配置文件创建(任意数量)。 然后,可以从这些2D
我有一个工作流,我将描述如下: [ Dump(query) ] ---+ | +---> [ Parquet(d
我是一名优秀的程序员,十分优秀!