mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 20:34:55 +10:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d8bf5471a |
@@ -14,10 +14,10 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up JDK 21
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '21'
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
|
||||
|
||||
Vendored
+1
-2
@@ -1,4 +1,3 @@
|
||||
{
|
||||
"java.configuration.updateBuildConfiguration": "disabled",
|
||||
"java.compile.nullAnalysis.mode": "disabled"
|
||||
"java.configuration.updateBuildConfiguration": "interactive"
|
||||
}
|
||||
@@ -1,95 +1,63 @@
|
||||
### 🛠️ Introduction
|
||||
<h3><a name="News"></a>Introduction<a href="#Introduction" class="section_anchor"></a></h3>
|
||||
<p align="justify">
|
||||
DIY Layout Creator (DIYLC) is a specialized software tool designed for hobbyists and electronics enthusiasts to create circuit layouts on stripboard, perfboard, PCB, and point-to-point wiring. It provides an intuitive, drag-and-drop interface for placing components, arranging connections, and visualizing circuit designs before assembly. With a built-in component library and customization options, it allows users to design layouts with precision and clarity. The software is particularly useful for designing, analyzing, and debugging guitar wiring diagrams, helping musicians and builders plan and troubleshoot custom wiring configurations for pickups, switches, and controls. Its versatility makes it an ideal solution for DIY electronics projects, prototyping, and documentation.</p>
|
||||
<br>
|
||||
<a href="https://github.com/bancika/diy-layout-creator/releases/latest">Click here</a> to get the latest version for all platforms.</a><br>
|
||||
<a href="https://github.com/bancika/diy-layout-creator/tree/wiki">Click here</a> to read the user documentation as well as developer documentation.<br>
|
||||
<br>
|
||||
<b>Mac users</b>: in most instances, the Gatekeeper will block DIYLC and mark it as damaged because it's a 3rd party app from an independent vendor (me). <a href="[https://support.apple.com/en-us/HT202491](https://support.apple.com/kb/ph18657?locale=en_US)">This document</a> covers how to allow DIYLC on your Mac.
|
||||
|
||||
DIY Layout Creator (DIYLC) is a specialized software tool designed for hobbyists and electronics enthusiasts to create circuit layouts on stripboard, perfboard, PCB, and point-to-point wiring.
|
||||
<h3><a name="Samples"></a>Samples<a href="#Samples" class="section_anchor"></a></h3>
|
||||
|
||||
It provides an intuitive, drag-and-drop interface for placing components, arranging connections, and visualizing circuit designs before assembly. With a built-in component library and customization options, it allows users to design layouts with precision and clarity.
|
||||
<h4>Point-to-point tube amplifier</h4>
|
||||
<p align="center"><a href="http://diy-fever.com/wordpress/wp-content/gallery/diylc/slo.png" rel="nofollow"><img src="https://diy-fever.com/wordpress/wp-content/gallery/diylc/cache/slo.png-nggid041072-ngg0dyn-450x350-00f0w010c010r110f110r010t010.png"></a></p>
|
||||
<h4>Guitar wiring</h4>
|
||||
<p align="center"><a href="http://diy-fever.com/wordpress/wp-content/gallery/diylc/travelcaster.png" rel="nofollow"><img src="https://diy-fever.com/nextgen-image/1073/450x350/34b70d759e46422208d61e376b4633dc"></a></p>
|
||||
<h4>PCB tube amplifier</h4>
|
||||
<p align="center"><a href="http://diy-fever.com/wordpress/wp-content/gallery/diylc/iic.png" rel="nofollow"><img src="https://diy-fever.com/nextgen-image/1070/450x350/ccb592ec5828b6f5bc75e840438918f1"></a></p>
|
||||
<h4>Perfboard guitar effect</h4>
|
||||
<p align="center"><a href="http://diy-fever.com/wordpress/wp-content/gallery/diylc/split.png" rel="nofollow"><img src="https://diy-fever.com/nextgen-image/1069/450x350/358e43165de40e9c4043726c9efde4a7"></a></p>
|
||||
|
||||
🎸 **Perfect for guitar pedal builders, guitar, synth, audio and HAM enthusiasts!** DIYLC is particularly useful for designing, analyzing, and debugging guitar wiring diagrams, helping musicians and builders plan and troubleshoot custom wiring configurations for pickups, switches, and controls. Its versatility makes it an ideal solution for DIY electronics projects, prototyping, and documentation.
|
||||
|
||||
### 🚀 Quick Links
|
||||
* **[⬇️ Download the latest release](https://github.com/bancika/diy-layout-creator/releases/latest)** for all platforms.
|
||||
* **[📄 Read the Wiki](https://github.com/bancika/diy-layout-creator/tree/wiki)** for free user and developer documentation.
|
||||
|
||||
> 🍎 **Mac users:** Gatekeeper may block DIYLC since it's from an independent developer. [Read this guide](https://support.apple.com/kb/ph18657?locale=en_US) on how to easily allow DIYLC on your Mac.
|
||||
|
||||
---
|
||||
|
||||
### 📖 The Official DIYLC Guide
|
||||
|
||||
<a href="https://www.diy-fever.com/diylc-book">
|
||||
<img src="https://www.diy-fever.com/diylc/book/book_v1_thumb.png" alt="DIYLC Official Guide" width="220" align="left" style="margin-right: 20px; margin-bottom: 20px;">
|
||||
</a>
|
||||
|
||||
**Master DIY Layout Creator and streamline your design workflow!**
|
||||
|
||||
The **Official DIYLC Guide (v1.0)** is a comprehensive 174-page eBook that goes way beyond the basics. It features step-by-step design workflows for everything from multi-layer PCBs to hot-rodded point-to-point tube amps. Learn to master advanced tools like the Virtual Multimeter, Netlist generation, the Guitar Wiring Analyzer, and the new AI Assistant.
|
||||
|
||||
🎉 **Launch Special:** Get **40% off** during our 14-day introductory sale! Buying v1.0 guarantees you free lifetime updates as the app evolves.
|
||||
|
||||
👉 **[Click here to grab your copy!](https://www.diy-fever.com/diylc-book)**
|
||||
|
||||
*Active Patreon supporters get an additional 50% off or a completely free copy. Check the [Patreon feed](https://www.patreon.com/c/user?u=5213116) for your VIP link!*
|
||||
|
||||
<br clear="all">
|
||||
|
||||
---
|
||||
|
||||
### 🖼️ Gallery & Samples
|
||||
|
||||
<p align="center">
|
||||
<img src="https://diy-fever.com/wordpress/wp-content/gallery/diylc/slo.png" width="48%" alt="Point-to-point tube amplifier">
|
||||
<img src="https://diy-fever.com/wordpress/wp-content/gallery/diylc/travelcaster.png" width="48%" alt="Guitar wiring">
|
||||
<br>
|
||||
<sup><i>Left: Point-to-point tube amplifier | Right: Guitar wiring</i></sup>
|
||||
<br><br>
|
||||
<img src="https://diy-fever.com/wordpress/wp-content/gallery/diylc/iic.png" width="48%" alt="PCB tube amplifier">
|
||||
<img src="https://diy-fever.com/wordpress/wp-content/gallery/diylc/split.png" width="48%" alt="Perfboard guitar effect">
|
||||
<br>
|
||||
<sup><i>Left: PCB tube amplifier | Right: Perfboard guitar effect</i></sup>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
### ✨ Key Features
|
||||
* 🆓 **Free for Life**: A true old-school offline app—the app you download is yours forever and the files you created are yours.
|
||||
* 💻 **Platform Independence:** Runs locally on any machine capable of running Java JRE/JDK 21 or newer.
|
||||
* 🖱️ **Intuitive UI:** Easy-to-use interface; most operations can be done seamlessly with a mouse.
|
||||
* 🎛️ **Versatile Designs:** Draw PCB, perfboard, stripboard, or point-to-point layouts, schematics, guitar wiring diagrams or custom faceplates.
|
||||
* 🔌 **Highly Extensible:** API allows custom plug-ins and new components to be added easily.
|
||||
* 🚀 **Optimized:** Improved performance and reduced memory consumption.
|
||||
* 💾 **Smart Defaults:** Save default values individually for each component property.
|
||||
* 🖨️ **Export Options:** Export outputs to image, PDF, or printer.
|
||||
* 📄 **Toner Transfer & Gerber:** Export PCB trace masks for toner transfer or Gerber files for fabrication.
|
||||
* 📋 **Bill of Materials:** Create a BOM within the project or export to multiple file formats.
|
||||
* 🔍 **Guitar Wiring Analysis:** Analyze guitar wirings and visualize detailed pickup configurations for each switch state.
|
||||
* ☁️ **Cloud Integration:** Share your projects, search the cloud, and download other users' designs.
|
||||
* 🤖 **AI Powered:** Features a built-in AI assistant to help answer general electronics questions, guide you through DIYLC's usability, and provide insights or troubleshooting for the specific circuit you are designing.
|
||||
* ⚡ **Circuit Analysis:** Various tools aimed to help you debug and analyze your circuits.
|
||||
* 📈 **SPICE Netlists:** Export circuits directly to SPICE-compatible netlists.
|
||||
|
||||
---
|
||||
|
||||
### 🐛 Support & Community
|
||||
* **Found a bug or have a feature request?** Head over to the [Issues page](https://github.com/bancika/diy-layout-creator/issues) to open a ticket.
|
||||
* **Need technical assistance or want to chat?** Join the discussion in our [Google Group](http://groups.google.com/group/diy-layout-creator).
|
||||
|
||||
---
|
||||
|
||||
### ❤️ Want to contribute?
|
||||
DIYLC is provided free of charge and can be used and redistributed freely. Building, testing, and maintaining this tool—while supporting our growing community—takes a significant amount of time and effort.
|
||||
|
||||
If you find DIYLC useful, here are the best ways you can support its future development:
|
||||
* 🧡 **[Become a Patreon](https://www.patreon.com/c/user?u=5213116):** Join the inner circle for exclusive perks.
|
||||
* 📖 **[Purchase the Official DIYLC Guide](https://www.diy-fever.com/diylc-book):** Level up your layout skills while directly supporting the app!
|
||||
* ☕ **[Make a PayPal donation](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=U6GLS8HLTSU88):** A one-time donation helps keep the lights on.
|
||||
* 📝 **Documentation:** Help us improve the [user manual](https://github.com/bancika/diy-layout-creator/blob/wiki/Manual.md) or other project docs.
|
||||
* 🧩 **Extend the App:** Read the [Component API Wiki](https://github.com/bancika/diy-layout-creator/blob/wiki/ComponentAPI.md) to add new components, or the [Plugin API Wiki](https://github.com/bancika/diy-layout-creator/blob/wiki/PluginAPI.md) to create new plug-ins.
|
||||
|
||||
---
|
||||
|
||||
### 📜 License Information
|
||||
The source code is released under the [GNU General Public License version 3](https://www.gnu.org/licenses/gpl-3.0.txt). Please contact the project owner to obtain a commercial license if you plan to use the source code, or any part of it, for commercial purposes.
|
||||
|
||||
### 🙌 Credits
|
||||
* Huge thanks to the online communities that contributed ideas and helped test the app: [DIY Stompboxes](http://www.diystompboxes.com/smfforum/), [AX84](http://ax84.com/bbs), and [Free Stompboxes](http://freestompboxes.org).
|
||||
* DIYLC is highly optimized thanks to [YourKit Java Profiler](http://www.yourkit.com/java/profiler/index.jsp). YourKit is kindly supporting open-source projects with its full-featured Java Profiler, which helped tremendously with memory and performance profiling. *YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications.*
|
||||
<h3><a name="Key Features"></a>Features<a href="#Features" class="section_anchor"></a></h3>
|
||||
<ul>
|
||||
<li>platform independence, will run on any machine having Java JRE/JDK 8 or newer </li>
|
||||
<li>easy to use interface, most of the operations can be done using mouse </li>
|
||||
<li>draw PCB, perfboard, stripboard or point-to-point circuit layouts layouts, schematics and guitar wiring diagrams </li>
|
||||
<li>high flexibility, has the API to allow plug-ins and new components to be added</li>
|
||||
<li>improved performance and reduced memory consumption compared to the previous versions </li>
|
||||
<li>save default values for each property of a component individually </li>
|
||||
<li>group components together and treat them as one, e.g. move, edit or delete </li>
|
||||
<li>export the output to image, PDF or printer </li>
|
||||
<li>export PCB trace mask suitable for toner transfer </li>
|
||||
<li>export PCB designs to Gerber for fabrication </li>
|
||||
<li>create a Bill of Materials as a part of the project or export it to few different file formats </li>
|
||||
<li>analyze guitar wirings and show detailed pickup configuration in each switch configuration</li>
|
||||
<li>zoom in/out feature </li>
|
||||
<li>configurable grid spacing on the project level </li>
|
||||
<li>auto update checks for new versions </li>
|
||||
<li>import files created with older versions of the application </li>
|
||||
<li>cloud feature - share your projects, search through the cloud and download other users' projects </li>
|
||||
<li>highlight connected areas to simplify validation and circuit debugging</li>
|
||||
<li>analyze guitar wiring diagrams and visualize pickup wirings for each switch configuration</li>
|
||||
<li>export circuits to SPICE-compatible netlists</li>
|
||||
</ul>
|
||||
<p>To report bugs or request a new feature go to <a href="https://github.com/bancika/diy-layout-creator/issues" rel="nofollow">Issues</a> page and create a new issue describing your problem or request. </p>
|
||||
<p>To join the discussion or request technical assistance, use the dedicated <a href="http://groups.google.com/group/diy-layout-creator" rel="nofollow">Discussion Group</a>. </p>
|
||||
<h3><a name="Want_to_contribute?"></a>Want to contribute?<a href="#Want_to_contribute?" class="section_anchor"></a></h3>
|
||||
<p align="justify"><strong>DIYLC is provided free of charge and can be used and redistributed freely. Please note that it takes a lot of time and effort to build, test and maintain it and to interact with the growing community of users. If you find DIYLC useful and want to support further development, these are some of the ways you can contribute</strong></p>
|
||||
<ul>
|
||||
<li><a href="https://www.patreon.com/c/user?u=5213116">Become a Patreon.</a></li>
|
||||
<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=U6GLS8HLTSU88">Make a one-time donation with PayPal.</a></li>
|
||||
<li>Help with adding the information to the <a href="https://github.com/bancika/diy-layout-creator/blob/wiki/Manual.md">user manual</a> or other project documentation.</li>
|
||||
<li>Extend the component base, read <a href="https://github.com/bancika/diy-layout-creator/blob/wiki/ComponentAPI.md" rel="nofollow">this wiki</a> to learn how to create new components. </li>
|
||||
<li>Add a new functionality though plug-ins, read <a href="https://github.com/bancika/diy-layout-creator/blob/wiki/PluginAPI.md" rel="nofollow">this wiki</a> to learn how to create new plug-ins. </li>
|
||||
</ul>
|
||||
<!--<p align="center"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=U6GLS8HLTSU88" rel="nofollow"><img src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif"></a> </p>-->
|
||||
<h3><a name="License_information"></a>License information<a href="#License_information" class="section_anchor"></a></h3>
|
||||
<p>Source code is released under <a href="https://www.gnu.org/licenses/gpl-3.0.txt">GNU General Public License version 3</a>. Contact the project owner to obtain a license in case you plan to use the source code, or any part of it, in commercial purposes. </p>
|
||||
<p></p>
|
||||
<h3><a name="Credits"></a>Credits<a href="#Credits" class="section_anchor"></a></h3>
|
||||
<ul>
|
||||
<li>Big thanks goes to folks from the following online communities for contributing ideas and helped test the app: <a href="http://www.diystompboxes.com/smfforum/" rel="nofollow">DIY Stompboxes</a>, <a href="http://ax84.com/bbs" rel="nofollow">AX84</a> and <a href="http://freestompboxes.org" rel="nofollow">Free Stompboxes</a>. </li>
|
||||
<li>I'm happy to report that DIYLC 4 is the fastest version ever. <a href="http://www.yourkit.com/java/profiler/index.jsp" rel="nofollow">YourKit Java Profiler</a> helped tremendously with memory and performance profiling and pointed me to places in the code that took longer to run or consumed more memory than I'd like them to. I strongly recommend this tool to anyone developing Java or .NET applications because it helps finding bottlenecks and allocation hot-spots very fast.<br><br>YourKit is kindly supporting open source projects with its full-featured Java Profiler.<br>YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications.<br>Take a look at YourKit's leading software products: <a href="http://www.yourkit.com/java/profiler/index.jsp" rel="nofollow">YourKit Java Profiler</a> and <a href="http://www.yourkit.com/.net/profiler/index.jsp" rel="nofollow">YourKit .NET Profiler</a> </li>
|
||||
</ul>
|
||||
|
||||
@@ -147,10 +147,3 @@ buildNumber.properties
|
||||
|
||||
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
|
||||
!/.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
######################
|
||||
###### Custom ######
|
||||
######################
|
||||
|
||||
# Deployment folder
|
||||
deploy/
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="DIYLCStarter" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||
<option name="ALTERNATIVE_JRE_PATH" value="temurin-21" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
||||
<option name="MAIN_CLASS_NAME" value="org.diylc.DIYLCStarter" />
|
||||
<module name="diylc-swing" />
|
||||
<option name="VM_PARAMETERS" value="-Xms1024m -Xmx4096m -Ddorg.diylc.debugAreaPerformance=true -Dorg.diylc.scriptRun=true -Ddorg.diylc.cloud.baseUrl=http://localhost:8080 -Dfile.encoding=UTF-8 --add-exports java.desktop/com.apple.eawt.event=ALL-UNNAMED --add-exports java.desktop/com.apple.eio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.desktop/java.awt.geom=ALL-UNNAMED" />
|
||||
<option name="VM_PARAMETERS" value="-Xms1024m -Xmx4096m -Ddorg.diylc.debugAreaPerformance=true -Dorg.diylc.scriptRun=true -Dfile.encoding=UTF-8 --add-exports java.desktop/com.apple.eawt.event=ALL-UNNAMED --add-exports java.desktop/com.apple.eio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.desktop/java.awt.geom=ALL-UNNAMED" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="org.diylc.*" />
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="RegressionTestRunner" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="org.diylc.RegressionTestRunner" />
|
||||
<module name="diylc-swing" />
|
||||
<option name="PROGRAM_PARAMETERS" value="$PROJECT_DIR$/../diylc-regression-data TEST" />
|
||||
<option name="VM_PARAMETERS" value="--add-exports java.desktop/com.apple.eawt.event=ALL-UNNAMED --add-exports java.desktop/com.apple.eio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.desktop/java.awt.geom=ALL-UNNAMED" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="org.diylc.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -1,123 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to build all Maven profiles and copy zip files to deployment folder
|
||||
# Usage: ./build-all-profiles.sh [to-deploy-folder]
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
# Parse arguments
|
||||
DEPLOY_DIR="${1:-}"
|
||||
|
||||
# Configuration
|
||||
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SWING_MODULE_DIR="${PROJECT_DIR}/diylc-swing"
|
||||
DEPLOY_DIR="${DEPLOY_DIR:-${PROJECT_DIR}/deploy}"
|
||||
|
||||
# List of profiles to build
|
||||
PROFILES=(
|
||||
"universal-zip"
|
||||
"linux-appimage"
|
||||
"win64-zip"
|
||||
"win64-installer"
|
||||
"mac-x86"
|
||||
"mac-arm"
|
||||
)
|
||||
|
||||
echo "=========================================="
|
||||
echo "Building all Maven profiles"
|
||||
echo "=========================================="
|
||||
echo "Project directory: ${PROJECT_DIR}"
|
||||
echo "Swing module directory: ${SWING_MODULE_DIR}"
|
||||
echo "Deployment directory: ${DEPLOY_DIR}"
|
||||
echo "Tests: Skipped"
|
||||
echo ""
|
||||
|
||||
# Create deployment directory if it doesn't exist
|
||||
mkdir -p "${DEPLOY_DIR}"
|
||||
|
||||
# Change to project root directory
|
||||
cd "${PROJECT_DIR}"
|
||||
|
||||
# Build each profile (clean before each one)
|
||||
TARGET_DIR="${SWING_MODULE_DIR}/target"
|
||||
TOTAL_ZIP_COUNT=0
|
||||
|
||||
for profile in "${PROFILES[@]}"; do
|
||||
echo "----------------------------------------"
|
||||
echo "Building profile: ${profile}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
# Clean and build from root, specifying the swing module and profile
|
||||
# This ensures dependencies (diylc-core, diylc-library) are built first
|
||||
mvn clean package -pl diylc-swing -am -P"${profile}" -DskipTests || {
|
||||
echo "ERROR: Failed to build profile ${profile}"
|
||||
echo "Continuing with next profile..."
|
||||
continue
|
||||
}
|
||||
|
||||
echo "✓ Profile ${profile} built successfully"
|
||||
|
||||
# Copy zip and exe files immediately after each build (before next clean)
|
||||
if [ -d "${TARGET_DIR}" ]; then
|
||||
echo "Looking for artifacts in ${TARGET_DIR}..."
|
||||
PROFILE_FILE_COUNT=0
|
||||
|
||||
# Find all zip files in target directory (excluding DIYLC-notarize.zip)
|
||||
while IFS= read -r -d '' zipfile; do
|
||||
filename=$(basename "${zipfile}")
|
||||
# Skip DIYLC-notarize.zip files
|
||||
if [[ "${filename}" != "DIYLC-notarize.zip" ]] && [ -f "${zipfile}" ]; then
|
||||
dest="${DEPLOY_DIR}/${filename}"
|
||||
|
||||
echo " → Copying: ${filename}"
|
||||
cp "${zipfile}" "${dest}"
|
||||
TOTAL_ZIP_COUNT=$((TOTAL_ZIP_COUNT + 1))
|
||||
PROFILE_FILE_COUNT=$((PROFILE_FILE_COUNT + 1))
|
||||
fi
|
||||
done < <(find "${TARGET_DIR}" -maxdepth 1 -type f -name "*.zip" -print0 2>/dev/null)
|
||||
|
||||
# Find all exe files in target directory
|
||||
while IFS= read -r -d '' exefile; do
|
||||
if [ -f "${exefile}" ]; then
|
||||
filename=$(basename "${exefile}")
|
||||
dest="${DEPLOY_DIR}/${filename}"
|
||||
|
||||
echo " → Copying: ${filename}"
|
||||
cp "${exefile}" "${dest}"
|
||||
TOTAL_ZIP_COUNT=$((TOTAL_ZIP_COUNT + 1))
|
||||
PROFILE_FILE_COUNT=$((PROFILE_FILE_COUNT + 1))
|
||||
fi
|
||||
done < <(find "${TARGET_DIR}" -maxdepth 1 -type f -name "*.exe" -print0 2>/dev/null)
|
||||
|
||||
if [ ${PROFILE_FILE_COUNT} -eq 0 ]; then
|
||||
echo " ⚠ Warning: No artifacts found for profile ${profile}"
|
||||
# List what's actually in the target directory for debugging
|
||||
echo " Debug: Files in target directory:"
|
||||
ls -la "${TARGET_DIR}"/*.{zip,exe} 2>/dev/null | head -5 || echo " (no zip/exe files found)"
|
||||
else
|
||||
echo " ✓ Copied ${PROFILE_FILE_COUNT} file(s) from ${profile}"
|
||||
fi
|
||||
else
|
||||
echo " ⚠ Warning: Target directory ${TARGET_DIR} does not exist"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
done
|
||||
|
||||
echo "=========================================="
|
||||
echo "Copying summary"
|
||||
echo "=========================================="
|
||||
if [ ${TOTAL_ZIP_COUNT} -eq 0 ]; then
|
||||
echo "No artifacts were copied"
|
||||
else
|
||||
echo "✓ Copied ${TOTAL_ZIP_COUNT} file(s) total to ${DEPLOY_DIR}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "Build and deployment complete!"
|
||||
echo "=========================================="
|
||||
echo "Deployment folder: ${DEPLOY_DIR}"
|
||||
echo "Files:"
|
||||
ls -lh "${DEPLOY_DIR}"/*.{zip,exe} 2>/dev/null || echo " (no zip/exe files found)"
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
<parent>
|
||||
<groupId>org.diylc</groupId>
|
||||
<artifactId>diylc-parent</artifactId>
|
||||
<version>6.4.0</version>
|
||||
<version>5.7.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>diylc-core</artifactId>
|
||||
<!-- No need to specify version - it inherits from parent -->
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -60,7 +60,7 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.22.1</version>
|
||||
<version>2.16.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.announcements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Utility methods for detecting and extracting URLs from announcements and HTML.
|
||||
*/
|
||||
public class AnnouncementUtils {
|
||||
|
||||
private static final Pattern HREF_PATTERN = Pattern.compile(
|
||||
"href=[\"']([^\"']+)[\"']", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
/**
|
||||
* Extracts the first URL found in the text or HTML.
|
||||
*
|
||||
* @param html text or HTML content
|
||||
* @return first URL found, or null if none
|
||||
*/
|
||||
public static String extractFirstUrl(String html) {
|
||||
List<String> urls = extractUrls(html);
|
||||
return urls.isEmpty() ? null : urls.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts all unique URLs found in the HTML href attributes in order of appearance.
|
||||
*
|
||||
* @param html text or HTML content
|
||||
* @return list of unique URLs
|
||||
*/
|
||||
public static List<String> extractUrls(String html) {
|
||||
List<String> urls = new ArrayList<String>();
|
||||
if (html == null || html.isEmpty()) {
|
||||
return urls;
|
||||
}
|
||||
|
||||
Matcher hrefMatcher = HREF_PATTERN.matcher(html);
|
||||
while (hrefMatcher.find()) {
|
||||
String url = hrefMatcher.group(1).trim();
|
||||
url = normalizeUrl(url);
|
||||
if (!urls.contains(url)) {
|
||||
urls.add(url);
|
||||
}
|
||||
}
|
||||
|
||||
return urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the HTML contains any link.
|
||||
*
|
||||
* @param html text or HTML content
|
||||
* @return true if at least one URL is detected, false otherwise
|
||||
*/
|
||||
public static boolean containsLink(String html) {
|
||||
return extractFirstUrl(html) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a URL to ensure it has a valid protocol if starting with www.
|
||||
*/
|
||||
public static String normalizeUrl(String url) {
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
String trimmed = url.trim();
|
||||
if (trimmed.startsWith("www.")) {
|
||||
return "http://" + trimmed;
|
||||
}
|
||||
return trimmed;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.diylc.core.ComponentGroup;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
/**
|
||||
@@ -45,21 +44,19 @@ public class ComponentTransferable implements Transferable, Serializable {
|
||||
public static final DataFlavor listFlavor = new DataFlavor(ComponentTransferable.class, "application/diylc");
|
||||
|
||||
private List<IDIYComponent<?>> components;
|
||||
private Set<ComponentGroup> groups;
|
||||
private String name;
|
||||
private Set<Set<IDIYComponent<?>>> groups;
|
||||
|
||||
public ComponentTransferable() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ComponentTransferable(List<IDIYComponent<?>> components, String name) {
|
||||
public ComponentTransferable(List<IDIYComponent<?>> components) {
|
||||
super();
|
||||
this.components = components;
|
||||
this.name = name;
|
||||
this.groups = null;
|
||||
}
|
||||
|
||||
public ComponentTransferable(List<IDIYComponent<?>> components, Set<ComponentGroup> groups) {
|
||||
public ComponentTransferable(List<IDIYComponent<?>> components, Set<Set<IDIYComponent<?>>> groups) {
|
||||
super();
|
||||
this.components = components;
|
||||
this.groups = groups;
|
||||
@@ -87,11 +84,7 @@ public class ComponentTransferable implements Transferable, Serializable {
|
||||
return components;
|
||||
}
|
||||
|
||||
public Set<ComponentGroup> getGroups() {
|
||||
public Set<Set<IDIYComponent<?>>> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
+25
-23
@@ -17,11 +17,15 @@
|
||||
*/
|
||||
package org.diylc.clipboard;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.diylc.core.ComponentGroup;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public class ComponentTransferableFactory {
|
||||
@@ -36,19 +40,13 @@ public class ComponentTransferableFactory {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ComponentTransferable build(Collection<IDIYComponent<?>> selectedComponents, Set<ComponentGroup> groups) {
|
||||
|
||||
public ComponentTransferable build(Collection<IDIYComponent<?>> selectedComponents, Set<Set<IDIYComponent<?>>> groups) {
|
||||
Set<IDIYComponent<?>> originalComponentSet = new HashSet<IDIYComponent<?>>(selectedComponents);
|
||||
List<IDIYComponent<?>> originalComponents = new ArrayList<IDIYComponent<?>>(selectedComponents);
|
||||
|
||||
Map<UUID, UUID> idMap = new HashMap<>();
|
||||
|
||||
List<IDIYComponent<?>> clonedComponents = originalComponents.stream(
|
||||
).map(x -> {
|
||||
try {
|
||||
IDIYComponent<?> clone = x.clone();
|
||||
clone.setId(UUID.randomUUID());
|
||||
idMap.put(x.getId(), clone.getId());
|
||||
return clone;
|
||||
return x.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
@@ -56,18 +54,22 @@ public class ComponentTransferableFactory {
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Set<ComponentGroup> clonedGroups = groups.stream()
|
||||
.map(group -> {
|
||||
Set<UUID> newIds = group.getComponentIds().stream()
|
||||
.map(idMap::get)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
// Only create group if it has at least one valid ID
|
||||
return newIds.isEmpty() ? null : new ComponentGroup(newIds, group.getName());
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
Set<Set<IDIYComponent<?>>> clonedGroups = new HashSet<Set<IDIYComponent<?>>>();
|
||||
|
||||
for (Set<IDIYComponent<?>> group : groups) {
|
||||
if (group.isEmpty())
|
||||
continue;
|
||||
|
||||
if (originalComponentSet.contains(group.iterator().next())) {
|
||||
Set<IDIYComponent<?>> clonedGroup = new HashSet<IDIYComponent<?>>();
|
||||
clonedGroups.add(clonedGroup);
|
||||
for (int i = 0; i < originalComponents.size(); i++) {
|
||||
if (group.contains(originalComponents.get(i))) {
|
||||
clonedGroup.add(clonedComponents.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ComponentTransferable(clonedComponents, clonedGroups);
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.common;
|
||||
|
||||
/**
|
||||
* The two ways a saved {@link BuildingBlock} can be placed on the canvas.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public enum BlockInstantiationMode {
|
||||
|
||||
/**
|
||||
* The block's components are cloned as individual, independently selectable components and
|
||||
* grouped together (the original, and only, behavior before composite mode was introduced).
|
||||
*/
|
||||
GROUP,
|
||||
|
||||
/**
|
||||
* The block's components are cloned and wrapped in a single
|
||||
* {@code org.diylc.components.composite.CompositeComponent} that behaves as one rigid
|
||||
* component with its own name, aggregating the control points of all its children.
|
||||
*/
|
||||
COMPOSITE
|
||||
}
|
||||
@@ -56,14 +56,14 @@ public class ComponentType implements Serializable {
|
||||
private boolean enableCache;
|
||||
private List<String[]> datasheet;
|
||||
private int datasheetCreationStepCount;
|
||||
|
||||
public ComponentType() {
|
||||
|
||||
public ComponentType() {
|
||||
}
|
||||
|
||||
public ComponentType(String name, String description, CreationMethod creationMethod, String category,
|
||||
String namePrefix, String author, Icon icon, Class<? extends IDIYComponent<?>> instanceClass, double zOrder,
|
||||
boolean flexibleZOrder, BomPolicy bomPolicy, boolean autoEdit, IComponentTransformer transformer,
|
||||
KeywordPolicy keywordPolicy, String keywordTag, boolean enableCache, List<String[]> datasheet,
|
||||
boolean flexibleZOrder, BomPolicy bomPolicy, boolean autoEdit, IComponentTransformer transformer,
|
||||
KeywordPolicy keywordPolicy, String keywordTag, boolean enableCache, List<String[]> datasheet,
|
||||
int datasheetCreationStepCount) {
|
||||
super();
|
||||
this.name = name;
|
||||
|
||||
@@ -68,9 +68,5 @@ public enum DrawOption {
|
||||
/**
|
||||
* Whether locked components should be rendered as transparent or not.
|
||||
*/
|
||||
LOCKED_ALPHA,
|
||||
/**
|
||||
* When applied, all colors will be converted to blackest black or whitest white
|
||||
*/
|
||||
MONOCHROMATIC;
|
||||
LOCKED_ALPHA;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package org.diylc.common;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.core.Project;
|
||||
@@ -54,7 +55,12 @@ public enum EventType {
|
||||
*/
|
||||
FILE_STATUS_CHANGED,
|
||||
/**
|
||||
* Called when component selection is changed. New list of components and control point map is attached as a
|
||||
* Called when selection rectangle is changed. Object of type {@link Rectangle} is the only
|
||||
* parameter and it contains the new selection rectangle.
|
||||
*/
|
||||
SELECTION_RECT_CHANGED,
|
||||
/**
|
||||
* Called when component selection is changed. New {@link ComponentSelection} is attached as a
|
||||
* parameter.
|
||||
*/
|
||||
SELECTION_CHANGED,
|
||||
@@ -112,10 +118,5 @@ public enum EventType {
|
||||
/**
|
||||
* Signals that the Cloud account is logged out.
|
||||
*/
|
||||
CLOUD_LOGGED_OUT,
|
||||
/**
|
||||
* Called when the mouse hovers over sticky control points (nodes) in tooltip mode.
|
||||
* Parameters: String text (semicolon-separated component and node names, or null), Point point.
|
||||
*/
|
||||
NODE_NAME_HOVER_TOOLTIP;
|
||||
CLOUD_LOGGED_OUT;
|
||||
}
|
||||
|
||||
@@ -25,28 +25,13 @@ import java.io.IOException;
|
||||
|
||||
public interface IBlockProcessor {
|
||||
|
||||
public static final String BLOCKS_KEY = "buildingBlocks";
|
||||
public static final String BLOCKS_KEY = "buildingBlocks";
|
||||
public static final String DEFAULT_BLOCKS_IMPORTED_KEY = "defaultBlocksImported";
|
||||
|
||||
/**
|
||||
* Prefix that marks a string as a reference to a building block rather than a component class
|
||||
* name. Used wherever components and blocks share a single identifier list, such as keyboard
|
||||
* shortcuts ({@code COMPONENT_SHORTCUT_KEY}) and the recently used list
|
||||
* ({@link org.diylc.common.IPlugInPort#RECENT_COMPONENTS_KEY}). A block identifier looks like
|
||||
* {@code "block:My Block Name"}.
|
||||
*/
|
||||
public static final String BLOCK_PREFIX = "block:";
|
||||
|
||||
void saveSelectionAsBlock(String blockName);
|
||||
|
||||
/**
|
||||
* Loads the block in the given {@link BlockInstantiationMode}. {@link BlockInstantiationMode#COMPOSITE}
|
||||
* (a single rigid component) is the default mode used by most call sites (see design decision D10 in
|
||||
* {@code docs/plans/composite-building-blocks.md}); {@link BlockInstantiationMode#GROUP} instantiates
|
||||
* the block as a group of loose components.
|
||||
*/
|
||||
void loadBlock(String blockName, BlockInstantiationMode mode) throws InvalidBlockException;
|
||||
|
||||
void loadBlock(String blockName) throws InvalidBlockException;
|
||||
|
||||
void deleteBlock(String blockName);
|
||||
|
||||
int importBlocks(String fileName) throws IOException;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.filter;
|
||||
package org.diylc.common;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.common;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.diylc.core.ComponentGroup;
|
||||
|
||||
/**
|
||||
* Interface for component grouping operations.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public interface IGroupProcessor {
|
||||
|
||||
/**
|
||||
* Returns the set of component groups in the current project. Each group is a set of components
|
||||
* that are grouped together.
|
||||
*
|
||||
* @return set of component groups
|
||||
*/
|
||||
Set<ComponentGroup> getComponentGroups();
|
||||
|
||||
/**
|
||||
* Groups all selected components.
|
||||
*/
|
||||
void groupSelectedComponents();
|
||||
|
||||
/**
|
||||
* Ungroups all selected components.
|
||||
*/
|
||||
void ungroupSelectedComponents();
|
||||
}
|
||||
|
||||
@@ -41,18 +41,16 @@ import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Template;
|
||||
import org.diylc.core.Theme;
|
||||
import org.diylc.core.measures.ResizeDimensions;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.filter.IComponentFilter;
|
||||
import org.diylc.test.ITestProcessor;
|
||||
|
||||
/**
|
||||
* Interface for communication between plug-ins and the application. Plug-ins may acquire
|
||||
* information or make changes through this interface. Application events are dispatched to plug-ins
|
||||
* through {@link MessageDispatcher}
|
||||
*
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*
|
||||
*
|
||||
* @see IPlugIn
|
||||
* @see MessageDispatcher
|
||||
* @see IMessageListener
|
||||
@@ -86,24 +84,18 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
public static final String RENUMBER_ON_PASTE_KEY = "renumberOnPaste";
|
||||
public static final String RULER_IN_SUBDIVISION_KEY = "rulerInSubdivision";
|
||||
public static final String CACHING_ENABLED_KEY = "cachingEnabled";
|
||||
public static final String FONT_SCALE_FACTOR_KEY = "fontScaleFactor";
|
||||
public static final String SHOW_RESIZE_DIMENSIONS_TOOLTIP_KEY = "showResizeDimensionsTooltip";
|
||||
public static final String AUTO_UNIT_CONVERSION_KEY = "autoUnitConversion";
|
||||
|
||||
|
||||
|
||||
public static final String RULER_IN_SUBDIVISION_2 = "base of 2";
|
||||
public static final String RULER_IN_SUBDIVISION_10 = "base of 10";
|
||||
public static final String RULER_IN_SUBDIVISION_DEFAULT = RULER_IN_SUBDIVISION_10;
|
||||
|
||||
|
||||
public static final String SNAP_TO_NONE = "None";
|
||||
public static final String SNAP_TO_GRID = "Grid";
|
||||
public static final String SNAP_TO_COMPONENTS = "Components";
|
||||
public static final String SNAP_TO_DEFAULT = SNAP_TO_GRID;
|
||||
|
||||
public static final String SHOW_NODE_NAME_TOOLTIPS_KEY = "showNodeNameTooltips";
|
||||
|
||||
|
||||
public static final String LOCKED_ALPHA = "lockedAlpha";
|
||||
|
||||
|
||||
public static final String LANGUAGE = "language";
|
||||
public static final String LANGUAGE_DEFAULT = "English";
|
||||
|
||||
@@ -116,25 +108,25 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
public static final int NOBUTTON = 0;
|
||||
public static final int BUTTON1 = 1;
|
||||
public static final int BUTTON2 = 2;
|
||||
public static final int BUTTON3 = 3;
|
||||
public static final int BUTTON3 = 3;
|
||||
|
||||
/**
|
||||
* Returns size of the canvas that takes project dimensions into account as well as zoom level.
|
||||
* Each dimension is calculated as the product of the actual size and the number of pixels per
|
||||
* unit. If <code>useZoom</code> is set to true, the result is scaled by zoom factor.
|
||||
*
|
||||
*
|
||||
* @param useZoom
|
||||
* @param includeExtraSpace
|
||||
*
|
||||
*
|
||||
* @return canvas dimensions
|
||||
*/
|
||||
Dimension getCanvasDimensions(boolean useZoom, boolean includeExtraSpace);
|
||||
|
||||
/**
|
||||
* Returns an instance of {@link Cursor} that should be used at the specified location.
|
||||
*
|
||||
*
|
||||
* Note: point coordinates are scaled for zoom factor.
|
||||
*
|
||||
*
|
||||
* @param point
|
||||
* @param ctrlDown
|
||||
* @param shiftDown
|
||||
@@ -145,14 +137,14 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
|
||||
/**
|
||||
* Returns an instance of currently loaded project.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Project getCurrentProject();
|
||||
|
||||
/**
|
||||
* Loads specified {@link Project}.
|
||||
*
|
||||
*
|
||||
* @param project
|
||||
* @param freshStart
|
||||
* @param filename file name when loading from a file
|
||||
@@ -166,22 +158,22 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
|
||||
/**
|
||||
* Loads a project from the specified file.
|
||||
*
|
||||
*
|
||||
* @param fileName
|
||||
*/
|
||||
void loadProjectFromFile(String fileName);
|
||||
|
||||
/**
|
||||
* Saves the current project into the specified file.
|
||||
*
|
||||
*
|
||||
* @param fileName
|
||||
* @param isBackup
|
||||
*/
|
||||
void saveProjectToFile(String fileName, boolean isBackup);
|
||||
|
||||
|
||||
/**
|
||||
* Exports the current project into one or more files - one per layer and potentially drill layer.
|
||||
*
|
||||
*
|
||||
* @param fileNameBase
|
||||
* @param g2d
|
||||
*/
|
||||
@@ -199,7 +191,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
|
||||
/**
|
||||
* Shows a user dialog if there are changes to confirm that it's safe to proceed.
|
||||
*
|
||||
*
|
||||
* @return true, if file actions (new, open, close) can be taken
|
||||
*/
|
||||
boolean allowFileAction();
|
||||
@@ -208,7 +200,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
* Returns all available {@link ComponentType}s classified by category. Result is a {@link Map}
|
||||
* between category name to a {@link List} of all {@link ComponentType}s that share that category
|
||||
* name.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<ComponentType>> getComponentTypes();
|
||||
@@ -216,7 +208,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
/**
|
||||
* Draws project on the provided {@link Graphics2D}. If the provided filter is not null, it will
|
||||
* be used to filter the components that are shown.
|
||||
*
|
||||
*
|
||||
* @param g2d
|
||||
* @param drawOptions specific drawing options
|
||||
* @param filter
|
||||
@@ -230,35 +222,35 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
|
||||
/**
|
||||
* Returns current zoom level where <code>zoomLevel = 1.0d</code> means 100%.
|
||||
*
|
||||
*
|
||||
* @return current zoom level
|
||||
*/
|
||||
double getZoomLevel();
|
||||
|
||||
/**
|
||||
* Changes current zoom level where <code>zoomLevel = 1.0d</code> means 100%
|
||||
*
|
||||
*
|
||||
* @param zoomLevel new zoom leve
|
||||
*/
|
||||
void setZoomLevel(double zoomLevel);
|
||||
|
||||
/**
|
||||
* Returns current version number.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
VersionNumber getCurrentVersionNumber();
|
||||
|
||||
|
||||
/**
|
||||
* Returns few most recent versions.
|
||||
*
|
||||
* Returns few most recent versions.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Version> getRecentUpdates();
|
||||
|
||||
/**
|
||||
* Adds a list of components to the project.
|
||||
*
|
||||
*
|
||||
* @param componentTransferable
|
||||
* @param autoGroup
|
||||
* @param assignNewNames
|
||||
@@ -277,7 +269,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
|
||||
/**
|
||||
* Sets default value for the specified property name for currently selected component types.
|
||||
*
|
||||
*
|
||||
* @param propertyName display name for property
|
||||
* @param value new default value, must not be null
|
||||
*/
|
||||
@@ -285,7 +277,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
|
||||
/**
|
||||
* Sets default value for the specified property name for projects.
|
||||
*
|
||||
*
|
||||
* @param clazz class to set defaults to
|
||||
* @param propertyName display name for property
|
||||
* @param value new default value, must not be null
|
||||
@@ -299,15 +291,6 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
*/
|
||||
List<PropertyWrapper> getMutualSelectionProperties();
|
||||
|
||||
/**
|
||||
* Available only during resizing, returns the dimensions of the component being resized.
|
||||
* Otherwise returns null.
|
||||
*
|
||||
* @return ResizeDimensions with width, height (in mm or in depending on configuration),
|
||||
* and length (if component implements IHaveLength), or null if not resizing
|
||||
*/
|
||||
ResizeDimensions getResizeDimensions();
|
||||
|
||||
void editSelection();
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.diylc.core.ExpansionMode;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.measures.Size;
|
||||
|
||||
public interface ISelectionProcessor extends IGroupProcessor {
|
||||
public interface ISelectionProcessor {
|
||||
|
||||
/**
|
||||
* Returns the current {@link ComponentTransferable}.
|
||||
@@ -89,6 +89,16 @@ public interface ISelectionProcessor extends IGroupProcessor {
|
||||
*/
|
||||
void rotateSelection(int direction);
|
||||
|
||||
/**
|
||||
* Groups all selected components.
|
||||
*/
|
||||
void groupSelectedComponents();
|
||||
|
||||
/**
|
||||
* Ungroups all selected components.
|
||||
*/
|
||||
void ungroupSelectedComponents();
|
||||
|
||||
/**
|
||||
* Mirrors selected components in the given axis.
|
||||
*
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class Percentage implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private BigDecimal value;
|
||||
|
||||
public Percentage(BigDecimal value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Percentage(double value) {
|
||||
this.value = BigDecimal.valueOf(value);
|
||||
}
|
||||
|
||||
public Percentage(int value) {
|
||||
this.value = BigDecimal.valueOf((long) value);
|
||||
}
|
||||
|
||||
public BigDecimal getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(BigDecimal value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((value == null) ? 0 : value.stripTrailingZeros().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Percentage other = (Percentage) obj;
|
||||
if (value == null) {
|
||||
if (other.value != null)
|
||||
return false;
|
||||
} else if (value.compareTo(other.value) != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (value == null) return "null%";
|
||||
BigDecimal stripped = value.stripTrailingZeros();
|
||||
return String.format("%s%%", stripped.toPlainString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
@@ -24,11 +24,8 @@ package org.diylc.common;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.core.IDynamicPropertySource;
|
||||
import org.diylc.core.IPropertyValidator;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
/**
|
||||
* Entity class for editable properties extracted from component objects. Represents a single
|
||||
@@ -68,8 +65,7 @@ public class PropertyWrapper implements Cloneable {
|
||||
public void readFrom(Object object) throws IllegalArgumentException, IllegalAccessException,
|
||||
InvocationTargetException, SecurityException, NoSuchMethodException {
|
||||
this.ownerObject = object;
|
||||
Object value = getGetter().invoke(object);
|
||||
this.value = value;
|
||||
this.value = getGetter().invoke(object);
|
||||
}
|
||||
|
||||
// public void readUniqueFrom(IDIYComponent component)
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -53,7 +52,6 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected UUID id = UUID.randomUUID();
|
||||
protected String name = "";
|
||||
|
||||
public static Color SELECTION_COLOR = Color.red;
|
||||
@@ -64,7 +62,6 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
public static Color LIGHT_METAL_COLOR = Color.decode("#EEEEEE");
|
||||
public static Color COPPER_COLOR = Color.decode("#DA8A67");
|
||||
public static Color GOLD_COLOR = Color.decode("#F4B301");
|
||||
public static Color BRASS_COLOR = Color.decode("#B8860B");
|
||||
public static Color FR4_COLOR = Color.decode("#6B9B6B");
|
||||
public static Color FR4_LIGHT_COLOR = Color.decode("#BABE71");
|
||||
public static Color PHENOLIC_COLOR = Color.decode("#F8EBB3");
|
||||
@@ -81,19 +78,6 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
if (id == null) {
|
||||
id = UUID.randomUUID();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canControlPointOverlap(int index) {
|
||||
return false;
|
||||
@@ -202,10 +186,6 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
field.setAccessible(true);
|
||||
Object value = field.get(this);
|
||||
|
||||
if (field.getName().equalsIgnoreCase("id")) {
|
||||
value = getId();
|
||||
}
|
||||
|
||||
// Deep copy point arrays.
|
||||
// TODO: something nicer
|
||||
if (value != null && value.getClass().isArray()
|
||||
@@ -294,6 +274,11 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSectionNames(int pointIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return true;
|
||||
|
||||
@@ -37,14 +37,16 @@ import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.LineStyle;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.core.*;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComponent<T> implements
|
||||
IHaveLength {
|
||||
public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComponent<T> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -149,7 +151,10 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
|
||||
path.curveTo(p[4].getX(), p[4].getY(), p[5].getX(), p[5].getY(), p[6].getX(), p[6].getY());
|
||||
}
|
||||
|
||||
Composite oldComposite = applyAlpha(g2d);
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
|
||||
drawCurve(path, g2d, componentState, drawingObserver);
|
||||
|
||||
@@ -332,12 +337,8 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
|
||||
// }
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Length")
|
||||
@EditableProperty
|
||||
public Size getLength() {
|
||||
return calculateLength();
|
||||
}
|
||||
|
||||
public Size calculateLength() {
|
||||
double d = 0;
|
||||
try {
|
||||
Point2D[] p = getControlPoints();
|
||||
|
||||
+9
-42
@@ -22,57 +22,24 @@
|
||||
package org.diylc.components;
|
||||
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.common.Percentage;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public abstract class AbstractTransparentComponent<T> extends AbstractComponent<T> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final boolean OUTLINE_MODE_WHILE_DRAGGING = false;
|
||||
|
||||
public static byte MAX_ALPHA_LEGACY = Byte.MAX_VALUE;
|
||||
public static int MAX_ALPHA = 100;
|
||||
public static byte MAX_ALPHA = 127;
|
||||
|
||||
@Deprecated
|
||||
protected Byte alpha;
|
||||
protected Byte alpha = MAX_ALPHA;
|
||||
|
||||
protected Percentage alphaPercent = new Percentage(100);
|
||||
|
||||
@EditableProperty(name = "Alpha")
|
||||
public Percentage getAlpha() {
|
||||
if (alphaPercent == null) {
|
||||
if (alpha != null) {
|
||||
alphaPercent = new Percentage(Math.round(100f * alpha / MAX_ALPHA_LEGACY));
|
||||
alpha = null;
|
||||
} else {
|
||||
alphaPercent = new Percentage(100);
|
||||
}
|
||||
@EditableProperty
|
||||
public Byte getAlpha() {
|
||||
if (alpha == null) {
|
||||
alpha = MAX_ALPHA;
|
||||
}
|
||||
return alphaPercent;
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public void setAlpha(Percentage alphaPercent) {
|
||||
this.alphaPercent = alphaPercent;
|
||||
}
|
||||
|
||||
public Composite applyAlpha(Graphics2D g2d, ComponentState componentState) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
double alpha = (OUTLINE_MODE_WHILE_DRAGGING && componentState == ComponentState.DRAGGING) ? 0 :
|
||||
getAlpha().getValue().doubleValue();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(alpha / 100d)));
|
||||
}
|
||||
return oldComposite;
|
||||
}
|
||||
|
||||
public Composite applyAlpha(Graphics2D g2d) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
double alpha = getAlpha().getValue().doubleValue();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(alpha / 100d)));
|
||||
}
|
||||
return oldComposite;
|
||||
public void setAlpha(Byte alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
}
|
||||
|
||||
-296
@@ -1,296 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.composite;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
/**
|
||||
* Instantiation of a {@code BuildingBlock} as a single, rigid component rather than a group of
|
||||
* loose ones. Wraps an embedded list of child components and aggregates their control points,
|
||||
* so it can be placed, moved, rotated and wired up like any other component while the netlist,
|
||||
* BOM and AI project description still see its individual terminals (see
|
||||
* {@link #getControlPointNodeName(int)}).
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
@ComponentDescriptor(
|
||||
name = "Building Block",
|
||||
description = "A group of components instantiated as a single rigid component",
|
||||
category = "Building Blocks",
|
||||
author = "Branislav Stojkovic",
|
||||
instanceNamePrefix = "BLK",
|
||||
zOrder = IDIYComponent.COMPONENT,
|
||||
flexibleZOrder = true,
|
||||
bomPolicy = BomPolicy.SHOW_ALL_NAMES,
|
||||
autoEdit = false,
|
||||
enableCache = false,
|
||||
transformer = CompositeComponentTransformer.class,
|
||||
hiddenInPalette = true)
|
||||
public class CompositeComponent extends AbstractTransparentComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<IDIYComponent<?>> childComponents = new ArrayList<IDIYComponent<?>>();
|
||||
|
||||
// Name of the building block this instance was created from. Drives its display identity in
|
||||
// the BOM, netlist report and AI project description (see ComponentProcessor.getDisplayTypeName).
|
||||
private String blockName;
|
||||
|
||||
// Free-form label the user can edit after placement, independent of blockName. Shown in the BOM.
|
||||
private String value;
|
||||
|
||||
// Flat index mapping a composite control point index to (child ordinal, child point index).
|
||||
// Rebuilt lazily since children never change after construction and the arrays are not
|
||||
// serialized (transient).
|
||||
private transient int[] childOf;
|
||||
private transient int[] pointOf;
|
||||
|
||||
/**
|
||||
* Required no-arg constructor, used reflectively by {@code ComponentProcessor} and XStream.
|
||||
*/
|
||||
public CompositeComponent() {
|
||||
super();
|
||||
}
|
||||
|
||||
private void buildIndexIfNeeded() {
|
||||
if (childOf != null) {
|
||||
return;
|
||||
}
|
||||
int total = 0;
|
||||
for (IDIYComponent<?> c : childComponents) {
|
||||
total += c.getControlPointCount();
|
||||
}
|
||||
int[] newChildOf = new int[total];
|
||||
int[] newPointOf = new int[total];
|
||||
int idx = 0;
|
||||
for (int ci = 0; ci < childComponents.size(); ci++) {
|
||||
IDIYComponent<?> c = childComponents.get(ci);
|
||||
int count = c.getControlPointCount();
|
||||
for (int pi = 0; pi < count; pi++) {
|
||||
newChildOf[idx] = ci;
|
||||
newPointOf[idx] = pi;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
childOf = newChildOf;
|
||||
pointOf = newPointOf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the embedded child components, in save order. Never {@code null}.
|
||||
*/
|
||||
public List<IDIYComponent<?>> getChildComponents() {
|
||||
if (childComponents == null) {
|
||||
childComponents = new ArrayList<IDIYComponent<?>>();
|
||||
}
|
||||
return childComponents;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Block", defaultable = false, sortOrder = 1)
|
||||
public String getBlockName() {
|
||||
return blockName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source block name. Deliberately not named {@code setBlockName} so that
|
||||
* {@code ComponentProcessor}'s getter/setter matching does not turn the "Block" property
|
||||
* editable in the property editor - it is metadata about the instance, not a value the user
|
||||
* should be able to change after placement.
|
||||
*/
|
||||
public void initBlockName(String blockName) {
|
||||
this.blockName = blockName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
buildIndexIfNeeded();
|
||||
return childOf.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
buildIndexIfNeeded();
|
||||
return childComponents.get(childOf[index]).getControlPoint(pointOf[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
buildIndexIfNeeded();
|
||||
childComponents.get(childOf[index]).setControlPoint(point, pointOf[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
buildIndexIfNeeded();
|
||||
return childComponents.get(childOf[index]).isControlPointSticky(pointOf[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canControlPointOverlap(int index) {
|
||||
buildIndexIfNeeded();
|
||||
return childComponents.get(childOf[index]).canControlPointOverlap(pointOf[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
buildIndexIfNeeded();
|
||||
return childComponents.get(childOf[index]).getControlPointVisibilityPolicy(pointOf[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
buildIndexIfNeeded();
|
||||
return childComponents.get(childOf[index]).getControlPointNodeName(pointOf[index]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The composite is always rigid: it moves and rotates as a unit and never stretches. See design
|
||||
* decision D4 in {@code docs/plans/composite-building-blocks.md}.
|
||||
*/
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createdIn(Project project) {
|
||||
for (IDIYComponent<?> c : getChildComponents()) {
|
||||
c.createdIn(project);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EditableProperty
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
for (IDIYComponent<?> c : getChildComponents()) {
|
||||
// Children always draw in their normal state - the composite draws its own selection
|
||||
// outline below instead of letting every child paint its own highlight.
|
||||
c.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
// Must not touch `components` - ComponentProcessor draws this on a default-constructed,
|
||||
// childless instance to build the palette icon.
|
||||
g2d.setColor(LIGHT_METAL_COLOR);
|
||||
g2d.fillRect(2, 2, width - 4, height - 4);
|
||||
g2d.setColor(METAL_COLOR);
|
||||
g2d.drawRect(2, 2, width - 4, height - 4);
|
||||
int halfW = width / 2;
|
||||
int halfH = height / 2;
|
||||
g2d.drawLine(halfW, 2, halfW, height - 2);
|
||||
g2d.drawLine(2, halfH, width - 2, halfH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deep-clones the composite together with all its children, so that two placed instances never
|
||||
* share child objects (that would make moving one instance move the other - see the "clone()
|
||||
* is the sharp edge" risk in {@code docs/plans/composite-building-blocks.md}). Preserves this
|
||||
* component's own id and every child's id, matching {@link AbstractComponent#clone()}'s
|
||||
* contract of copying identity by default - callers that need a genuinely new component
|
||||
* reassign ids themselves, exactly as {@code BuildingBlockManager.loadBlock} does when it
|
||||
* clones each source component individually to place a brand new instance of a block. This also
|
||||
* keeps id-sensitive reflective comparisons (like the default {@code equalsTo} most child
|
||||
* component classes inherit) working correctly between a composite and its own clone, which the
|
||||
* undo dirty-check in {@code Presenter.notifyProjectModifiedIfNeeded} relies on.
|
||||
*/
|
||||
@Override
|
||||
public IDIYComponent<String> clone() throws CloneNotSupportedException {
|
||||
CompositeComponent clone = new CompositeComponent();
|
||||
clone.setId(getId());
|
||||
clone.setName(getName());
|
||||
clone.blockName = this.blockName;
|
||||
clone.value = this.value;
|
||||
// matches AbstractComponent.clone(), which shallow-copies the Percentage reference
|
||||
clone.setAlpha(getAlpha());
|
||||
List<IDIYComponent<?>> clonedComponents = new ArrayList<IDIYComponent<?>>(getChildComponents().size());
|
||||
for (IDIYComponent<?> c : getChildComponents()) {
|
||||
clonedComponents.add(c.clone());
|
||||
}
|
||||
clone.childComponents = clonedComponents;
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden because {@link AbstractComponent#equalsTo(IDIYComponent)} compares the
|
||||
* {@code components} field with {@code List.equals()}, which falls back to child object
|
||||
* identity since no component class overrides {@code Object.equals()} - two structurally
|
||||
* identical composites built from different object graphs (e.g. an original and its clone)
|
||||
* would otherwise never compare equal, defeating the undo dirty-check in
|
||||
* {@code Presenter.notifyProjectModifiedIfNeeded}.
|
||||
*/
|
||||
@Override
|
||||
public boolean equalsTo(IDIYComponent<?> other) {
|
||||
if (!(other instanceof CompositeComponent)) {
|
||||
return false;
|
||||
}
|
||||
CompositeComponent o = (CompositeComponent) other;
|
||||
if (!Objects.equals(getName(), o.getName()) || !Objects.equals(blockName, o.blockName)
|
||||
|| !Objects.equals(value, o.value) || !Objects.equals(getAlpha(), o.getAlpha())) {
|
||||
return false;
|
||||
}
|
||||
List<IDIYComponent<?>> otherComponents = o.getChildComponents();
|
||||
if (getChildComponents().size() != otherComponents.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < childComponents.size(); i++) {
|
||||
if (!childComponents.get(i).equalsTo(otherComponents.get(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.composite;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.presenter.ComponentProcessor;
|
||||
|
||||
/**
|
||||
* Rotates and mirrors a {@link CompositeComponent} by delegating to each child's own
|
||||
* {@link IComponentTransformer}, around the same centre for every child so the assembly stays
|
||||
* geometrically consistent. If any child's type cannot rotate (or mirror), the whole composite
|
||||
* reports that it cannot either - silently leaving one child un-rotated would be worse (see
|
||||
* design decision D9 in {@code docs/plans/composite-building-blocks.md}).
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class CompositeComponentTransformer implements IComponentTransformer {
|
||||
|
||||
@Override
|
||||
public boolean canRotate(IDIYComponent<?> component) {
|
||||
CompositeComponent composite = (CompositeComponent) component;
|
||||
if (composite.getChildComponents().isEmpty())
|
||||
return false;
|
||||
for (IDIYComponent<?> child : composite.getChildComponents()) {
|
||||
if (!childTransformer(child).canRotate(child))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMirror(IDIYComponent<?> component) {
|
||||
CompositeComponent composite = (CompositeComponent) component;
|
||||
if (composite.getChildComponents().isEmpty())
|
||||
return false;
|
||||
for (IDIYComponent<?> child : composite.getChildComponents()) {
|
||||
if (!childTransformer(child).canMirror(child))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mirroringChangesCircuit() {
|
||||
// This transformer instance is shared by every CompositeComponent (ComponentProcessor caches
|
||||
// one instance per class), so it has no access to a specific composite's children here.
|
||||
// Conservatively assume mirroring can change the circuit, so the user is always warned - a
|
||||
// spurious confirmation is far cheaper than silently flipping a board's pinout.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotate(IDIYComponent<?> component, Point2D center, int direction) {
|
||||
CompositeComponent composite = (CompositeComponent) component;
|
||||
for (IDIYComponent<?> child : composite.getChildComponents()) {
|
||||
childTransformer(child).rotate(child, center, direction);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mirror(IDIYComponent<?> component, Point2D center, int direction) {
|
||||
CompositeComponent composite = (CompositeComponent) component;
|
||||
for (IDIYComponent<?> child : composite.getChildComponents()) {
|
||||
childTransformer(child).mirror(child, center, direction);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private IComponentTransformer childTransformer(IDIYComponent<?> child) {
|
||||
ComponentType type =
|
||||
ComponentProcessor.getInstance().extractComponentTypeFrom((Class) child.getClass());
|
||||
return type.getTransformer();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package org.diylc.core;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ComponentGroup implements Serializable {
|
||||
|
||||
private Set<UUID> componentIds;
|
||||
private String name;
|
||||
|
||||
public ComponentGroup(Set<UUID> componentIds) {
|
||||
this.componentIds = componentIds;
|
||||
}
|
||||
|
||||
public ComponentGroup(Set<UUID> componentIds, String name) {
|
||||
this.componentIds = componentIds;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static ComponentGroup from(Collection<IDIYComponent<?>> components, String name) {
|
||||
Set<UUID> componentIds = components.stream()
|
||||
.map(IDIYComponent::getId)
|
||||
.filter(id -> id != null)
|
||||
.collect(Collectors.toSet());
|
||||
return new ComponentGroup(componentIds, name);
|
||||
}
|
||||
|
||||
public Set<UUID> getComponentIds() {
|
||||
return componentIds;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import java.awt.Graphics2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -56,10 +55,6 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
|
||||
public static final int WIRING = 5;
|
||||
public static final int TEXT = 6;
|
||||
|
||||
UUID getId();
|
||||
|
||||
void setId(UUID id);
|
||||
|
||||
/**
|
||||
* @return component instance name.
|
||||
*/
|
||||
@@ -137,6 +132,13 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
|
||||
*/
|
||||
String getInternalLinkName(int index1, int index2);
|
||||
|
||||
/**
|
||||
* @param pointIndex
|
||||
* @return name of the internal section containing the specified point, or null if the component does not have internal sections.
|
||||
* One point can be shared between multiple sections, in which case, the result may contain more than one element.
|
||||
*/
|
||||
String[] getSectionNames(int pointIndex);
|
||||
|
||||
/**
|
||||
* @param pointIndex
|
||||
* @return true if the control point can move without affecting other points' position, false otherwise
|
||||
@@ -197,4 +199,13 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
|
||||
* @param project
|
||||
*/
|
||||
void createdIn(Project project);
|
||||
|
||||
/**
|
||||
* Returns whether this component is polarized (direction matters for electronic function).
|
||||
* Default implementation returns true, components that are not polarized should override this.
|
||||
* @return true if the component is polarized, false otherwise
|
||||
*/
|
||||
default boolean isPolarized() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.core;
|
||||
|
||||
import org.diylc.core.measures.Size;
|
||||
|
||||
public interface IHaveLength {
|
||||
|
||||
Size calculateLength();
|
||||
}
|
||||
@@ -23,9 +23,13 @@ package org.diylc.core;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.diylc.appframework.update.VersionNumber;
|
||||
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -63,7 +67,6 @@ public class Project implements Serializable, Cloneable {
|
||||
private Integer dotSpacing;
|
||||
private List<IDIYComponent<?>> components;
|
||||
private Set<Set<IDIYComponent<?>>> groups;
|
||||
private Set<ComponentGroup> groupsEx;
|
||||
private Set<Integer> lockedLayers;
|
||||
private Set<IDIYComponent<?>> lockedComponents;
|
||||
private Set<Integer> hiddenLayers;
|
||||
@@ -72,7 +75,6 @@ public class Project implements Serializable, Cloneable {
|
||||
public Project() {
|
||||
components = new ArrayList<IDIYComponent<?>>();
|
||||
groups = new HashSet<Set<IDIYComponent<?>>>();
|
||||
groupsEx = new HashSet<>();
|
||||
lockedLayers = new HashSet<Integer>();
|
||||
hiddenLayers = new HashSet<Integer>();
|
||||
lockedComponents = new HashSet<IDIYComponent<?>>();
|
||||
@@ -151,35 +153,22 @@ public class Project implements Serializable, Cloneable {
|
||||
|
||||
/**
|
||||
* List of components sorted by z-order ascending.
|
||||
* s
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<IDIYComponent<?>> getComponents() {
|
||||
return components;
|
||||
}
|
||||
|
||||
public Set<ComponentGroup> getGroupsEx() {
|
||||
if (groupsEx == null) {
|
||||
groupsEx = new HashSet<>();
|
||||
|
||||
if (groups != null && !groups.isEmpty()) {
|
||||
for (Set<IDIYComponent<?>> group : groups) {
|
||||
Set<IDIYComponent<?>> nonNullIds =
|
||||
group.stream().filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
if (!nonNullIds.isEmpty()) {
|
||||
ComponentGroup newGroup = ComponentGroup.from(group, null);
|
||||
groupsEx.add(newGroup);
|
||||
}
|
||||
}
|
||||
groups.clear();
|
||||
}
|
||||
}
|
||||
groupsEx.removeAll(groupsEx.stream().
|
||||
filter(x -> x.getComponentIds() == null ||
|
||||
x.getComponentIds().stream().noneMatch(Objects::nonNull)).collect(Collectors.toSet()));
|
||||
return groupsEx;
|
||||
/**
|
||||
* Set of grouped components.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<Set<IDIYComponent<?>>> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
||||
public Set<IDIYComponent<?>> getLockedComponents() {
|
||||
if (lockedComponents == null)
|
||||
lockedComponents = new HashSet<IDIYComponent<?>>();
|
||||
@@ -303,11 +292,6 @@ public class Project implements Serializable, Cloneable {
|
||||
return false;
|
||||
} else if (!groups.equals(other.groups))
|
||||
return false;
|
||||
if (groupsEx == null) {
|
||||
if (other.groupsEx != null)
|
||||
return false;
|
||||
} else if (!groupsEx.equals(other.groupsEx))
|
||||
return false;
|
||||
if (lockedLayers == null) {
|
||||
if (other.lockedLayers != null)
|
||||
return false;
|
||||
@@ -372,15 +356,12 @@ public class Project implements Serializable, Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
for (ComponentGroup group : this.getGroupsEx()) {
|
||||
// Filter out null IDs when cloning groups
|
||||
Set<UUID> validIds = group.getComponentIds().stream()
|
||||
.filter(id -> id != null)
|
||||
.collect(Collectors.toSet());
|
||||
// Only add group if it has valid component IDs
|
||||
if (!validIds.isEmpty()) {
|
||||
project.getGroupsEx().add(new ComponentGroup(validIds, group.getName()));
|
||||
for (Set<IDIYComponent<?>> group : this.groups) {
|
||||
Set<IDIYComponent<?>> cloneGroup = new HashSet<IDIYComponent<?>>();
|
||||
for (IDIYComponent<?> component : group) {
|
||||
cloneGroup.add(cloneMap.get(component));
|
||||
}
|
||||
project.groups.add(cloneGroup);
|
||||
}
|
||||
|
||||
for (IDIYComponent<?> component : this.getLockedComponents()) {
|
||||
|
||||
@@ -123,18 +123,9 @@ public @interface ComponentDescriptor {
|
||||
boolean enableDatasheet() default false;
|
||||
|
||||
/**
|
||||
* If datasheet is enabled, this property determines how many columns define a component, e.g. in how many steps we can instantiate a component
|
||||
*
|
||||
* If datasheet is enabled, this property determines how many columns define a component, e.g. in how many steps we can instantiate a component
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int datasheetCreationStepCount() default 0;
|
||||
|
||||
/**
|
||||
* @return true if the component type should not be listed in the palette (toolbox and
|
||||
* component tree), while still being resolvable via
|
||||
* {@code ComponentProcessor.extractComponentTypeFrom} for netlist, BOM and name
|
||||
* generation purposes. Used by component types that are only ever created
|
||||
* programmatically, e.g. {@code CompositeComponent}.
|
||||
*/
|
||||
boolean hiddenInPalette() default false;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,5 @@ import java.lang.annotation.RetentionPolicy;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface PercentEditor {
|
||||
|
||||
public int minValue() default 0;
|
||||
|
||||
public int maxValue() default 100;
|
||||
public byte _100PercentValue();
|
||||
}
|
||||
|
||||
@@ -1,84 +1,80 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.core.images;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Loads image resources as Icons.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public enum IconLoader {
|
||||
|
||||
About("about.png"), Add("add.png"), BOM("bom.png"), Back("back.png"), BlackBoard(
|
||||
"blackboard.png"), Bug("bug.png"), CSV("csv.png"), Chest("chest.png"), Component(
|
||||
"component.png"), Copy("copy.png"), Cut("cut.png"), Delete("delete.png"), DiskBlue(
|
||||
"disk_blue.png"), DocumentEdit("document_edit.png"), DocumentPlainYellow(
|
||||
"document_plain_yellow.png"), Donate("donate.png"), EditComponent(
|
||||
"edit_component.png"), ElementsSelection("elements_selection.png"), Error("error.png"), Excel(
|
||||
"excel.png"), Exit("exit.png"), Faq("faq.png"), FolderOut("folder_out.png"), FormGreen(
|
||||
"form_green.png"), Front("front.png"), Garbage("garbage.png"), Gears("gears.png"), Group(
|
||||
"group.png"), HTML("html.png"), IconLarge("icon_large.png"), IconMedium(
|
||||
"icon_medium.png"), IconSmall("icon_small.png"), IdCard("id_card.png"), IdCardAdd(
|
||||
"id_card_add.png"), Image("image.png"), LightBulbOff("lightbulb_off.png"), LightBulbOn(
|
||||
"lightbulb_on.png"), Manual("manual.png"), MoveSmall("move_small.png"), NavigateCheck(
|
||||
"navigate_check.png"), NotebookAdd("notebook_add.png"), PDF("pdf.png"), Paste(
|
||||
"paste.png"), Pens("pens.png"), PhotoScenery("photo_scenery.png"), Plugin(
|
||||
"plugin.png"), Print("print.png"), SaveAs("save_as.png"), Schaller("schaller.png"), Selection(
|
||||
"selection.png"), Size("size.png"), Sort("sort.png"), TraceMask("trace_mask.png"), Undo(
|
||||
"undo.png"), Ungroup("ungroup.png"), Upload("upload.png"), Warning(
|
||||
"warning.png"), WindowColors("window_colors.png"), WindowGear("window_gear.png"), Wrench(
|
||||
"wrench.png"), ZoomSmall("zoom_small.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
private IconLoader(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
java.net.URL imgURL = getClass().getResource("/diylc-core-images/" + name);
|
||||
if (imgURL != null) {
|
||||
return new ImageIcon(imgURL, name);
|
||||
} else {
|
||||
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Image getImage() {
|
||||
BufferedImage img = null;
|
||||
try {
|
||||
img = ImageIO.read(getClass().getResourceAsStream("/diylc-core-images/" + name));
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
|
||||
}
|
||||
return img;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.core.images;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
/**
|
||||
* Loads image resources as Icons.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public enum IconLoader {
|
||||
|
||||
Delete("delete.png"), Add("add.png"), FolderOut("folder_out.png"), Garbage("garbage.png"), DiskBlue("disk_blue.png"), SaveAs(
|
||||
"save_as.png"), Exit("exit.png"), DocumentPlainYellow("document_plain_yellow.png"), PhotoScenery(
|
||||
"photo_scenery.png"), LightBulbOn("lightbulb_on.png"), LightBulbOff("lightbulb_off.png"), NotebookAdd(
|
||||
"notebook_add.png"), FormGreen("form_green.png"), Gears("gears.png"), About("about.png"), WindowColors(
|
||||
"window_colors.png"), WindowGear("window_gear.png"), NavigateCheck("navigate_check.png"), Undo("undo.png"), Error(
|
||||
"error.png"), Warning("warning.png"), ZoomSmall("zoom_small.png"), MoveSmall("move_small.png"), Print("print.png"), PDF(
|
||||
"pdf.png"), Excel("excel.png"), CSV("csv.png"), HTML("html.png"), Image("image.png"), Cut("cut.png"), Copy(
|
||||
"copy.png"), Paste("paste.png"), Selection("selection.png"), BOM("bom.png"), BlackBoard("blackboard.png"), IdCard(
|
||||
"id_card.png"), IdCardAdd("id_card_add.png"), Chest("chest.png"), Upload("upload.png"), Wrench("wrench.png"), Group(
|
||||
"group.png"), Ungroup("ungroup.png"), TraceMask("trace_mask.png"), Faq("faq.png"), Component("component.png"), Plugin(
|
||||
"plugin.png"), Manual("manual.png"), Donate("donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
|
||||
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
|
||||
"edit_component.png"), Size("size.png"), Front("front.png"), Back("back.png"), Pens("pens.png"), Sort("sort.png"), ElementsSelection(
|
||||
"elements_selection.png"), Schaller("schaller.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
private IconLoader(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
java.net.URL imgURL = getClass().getResource("/diylc-core-images/" + name);
|
||||
if (imgURL != null) {
|
||||
return new ImageIcon(imgURL, name);
|
||||
} else {
|
||||
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Image getImage() {
|
||||
BufferedImage img = null;
|
||||
try {
|
||||
img = ImageIO.read(getClass().getResourceAsStream("/diylc-core-images/" + name));
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
|
||||
}
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,10 +118,4 @@ public class Resistance extends AbstractMeasure<ResistanceUnit> {
|
||||
}
|
||||
throw new IllegalArgumentException("Could not parse resistance: " + value);
|
||||
}
|
||||
|
||||
public Double getNormalizedValue() {
|
||||
if (value == null || unit == null)
|
||||
return null;
|
||||
return value * unit.getFactor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* DIY Layout Creator (DIYLC).
|
||||
* Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
*
|
||||
* This file is part of DIYLC.
|
||||
*
|
||||
* DIYLC is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DIYLC is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package org.diylc.core.measures;
|
||||
|
||||
/**
|
||||
* Record containing resize dimensions for a component being resized.
|
||||
*
|
||||
* @param width the width of the component (in mm or in, depending on configuration)
|
||||
* @param height the height of the component (in mm or in, depending on configuration)
|
||||
* @param length the length of the component (if it implements IHaveLength), null otherwise
|
||||
*/
|
||||
public record ResizeDimensions(Size width, Size height, Size length) {
|
||||
}
|
||||
|
||||
@@ -46,21 +46,11 @@ public class Size extends AbstractMeasure<SizeUnit> implements Comparable<Size>
|
||||
return getValue() * getUnit().getFactor() / SizeUnit.in.getFactor() * Constants.PIXELS_PER_INCH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this size to the given unit. Returns a new Size with the same
|
||||
* physical length expressed in the target unit.
|
||||
*/
|
||||
public Size convertToUnits(SizeUnit unit) {
|
||||
public double convertToUnits(SizeUnit unit) {
|
||||
if (unit == getUnit()) {
|
||||
return new Size(roundTo4Decimals(getValue()), unit);
|
||||
return this.getValue();
|
||||
}
|
||||
double lengthInBase = getValue() * getUnit().getFactor();
|
||||
double valueInTargetUnit = lengthInBase / unit.getFactor();
|
||||
return new Size(roundTo4Decimals(valueInTargetUnit), unit);
|
||||
}
|
||||
|
||||
private static double roundTo4Decimals(double value) {
|
||||
return Math.round(value * 10000) / 10000.0;
|
||||
return convertToPixels() * SizeUnit.px.getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,35 +23,18 @@ package org.diylc.core.measures;
|
||||
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public enum SizeUnit implements Unit {
|
||||
|
||||
px(25.4d / Constants.PIXELS_PER_INCH, SizeUnitType.Digital),
|
||||
mm(1d, SizeUnitType.Metric),
|
||||
cm(10d, SizeUnitType.Metric),
|
||||
m(1e3d, SizeUnitType.Metric),
|
||||
in(25.4d, SizeUnitType.Imperial),
|
||||
ft(25.4d * 12, SizeUnitType.Imperial),
|
||||
yd(9144d, SizeUnitType.Imperial);
|
||||
px(25.4d / Constants.PIXELS_PER_INCH), mm(1d), cm(10d), m(1e3d), in(25.4d), ft(25.4d * 12), yd(9144d);
|
||||
|
||||
double factor;
|
||||
SizeUnitType type;
|
||||
|
||||
private SizeUnit(double factor, SizeUnitType type) {
|
||||
private SizeUnit(double factor) {
|
||||
this.factor = factor;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFactor() {
|
||||
return factor;
|
||||
}
|
||||
|
||||
public SizeUnitType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static final Map<SizeUnit, SizeUnit> ConversionMapping =
|
||||
Map.of(mm, in, cm, in, m, yd, in, mm, ft, cm, yd, m);
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.diylc.core.measures;
|
||||
|
||||
public enum SizeUnitType {
|
||||
Metric, Imperial, Digital
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.diylc.filter;
|
||||
|
||||
import org.diylc.core.IBoard;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.gerber.GerberRenderMode;
|
||||
import org.diylc.core.gerber.IGerberComponent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class SilkScreenFilter implements IComponentFilter {
|
||||
|
||||
@Override
|
||||
public boolean testComponent(IDIYComponent<?> component) {
|
||||
if (component instanceof IBoard board) {
|
||||
return board.shouldExportToGerber();
|
||||
}
|
||||
if (!(component instanceof IGerberComponent gerberComponent)) {
|
||||
return false;
|
||||
}
|
||||
Set<GerberRenderMode> gerberRenderModes = gerberComponent.getGerberRenderModes();
|
||||
return gerberRenderModes.contains(GerberRenderMode.Outline);
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class NetlistBuilder {
|
||||
|
||||
public static final float eps = 4; // consider any nodes closer than this as connected
|
||||
|
||||
public static int MAX_SWITCH_COMBINATIONS = 1024;
|
||||
public static int MAX_SWITCH_COMBINATIONS = 256;
|
||||
|
||||
private static final String MAX_SWITCH_COMBINATIONS_ERROR = LangUtil
|
||||
.translate("Maximum number of switching combinations exceeded. Allowed: %s, actual: %s");
|
||||
|
||||
@@ -52,7 +52,8 @@ public class Node implements Comparable<Node> {
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return component.getControlPointNodeName(pointIndex);
|
||||
String[] section = component.getSectionNames(pointIndex);
|
||||
return (section == null || section.length > 1 ? "" : section[0] + ".") + component.getControlPointNodeName(pointIndex);
|
||||
}
|
||||
|
||||
public Point2D getPoint2D() {
|
||||
|
||||
@@ -234,7 +234,7 @@ public class Tree {
|
||||
|
||||
public Set<IDIYComponent<?>> extractComponents(Set<String> types) {
|
||||
Set<IDIYComponent<?>> res = new HashSet<IDIYComponent<?>>();
|
||||
if (leaf != null && (types == null || types.contains(leaf.getComponent().getClass().getCanonicalName()))) {
|
||||
if (leaf != null && types.contains(leaf.getComponent().getClass().getCanonicalName())) {
|
||||
res.add(leaf.getComponent());
|
||||
} else if (children != null) {
|
||||
for (Tree t : children) {
|
||||
|
||||
+1
-2
@@ -175,8 +175,7 @@ public class AiProjectBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
return new AiComponent(component.getName(),
|
||||
ComponentProcessor.getDisplayTypeName(component, componentType),
|
||||
return new AiComponent(component.getName(), componentType.getName(),
|
||||
component.getValue() == null ? null : component.getValue().toString(),
|
||||
fromPos, toPos, pos, terminals.isEmpty() ? null : terminals);
|
||||
}
|
||||
|
||||
+12
-22
@@ -38,7 +38,6 @@ import org.diylc.core.ISwitch;
|
||||
import org.diylc.netlist.*;
|
||||
import org.diylc.plugins.chatbot.model.*;
|
||||
import org.diylc.plugins.cloud.model.IServiceAPI;
|
||||
import org.diylc.plugins.cloud.service.CloudException;
|
||||
import org.diylc.plugins.cloud.service.NotLoggedInException;
|
||||
import org.diylc.presenter.ComponentProcessor;
|
||||
import org.diylc.presenter.ContinuityArea;
|
||||
@@ -63,8 +62,6 @@ public class ChatbotService {
|
||||
|
||||
private final static Logger LOG = Logger.getLogger(ChatbotService.class);
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
public static final String SERVER_ERROR_PLEASE_TRY_AGAIN = "Server error, please try again.";
|
||||
|
||||
static {
|
||||
MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
@@ -109,15 +106,15 @@ public class ChatbotService {
|
||||
|
||||
private IChatbotAPI getService() {
|
||||
if (service == null) {
|
||||
String serviceUrl = System.getProperty("org.diylc.cloud.baseUrl",
|
||||
ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1")) + "/ai";
|
||||
String serviceUrl =
|
||||
ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1/ai");
|
||||
ProxyFactory factory = new ProxyFactory(new PhpFlatProxy());
|
||||
service = factory.createProxy(IChatbotAPI.class, serviceUrl);
|
||||
}
|
||||
return service;
|
||||
}
|
||||
|
||||
public String promptChatbot(String prompt) throws NotLoggedInException, CloudException {
|
||||
public String promptChatbot(String prompt) throws NotLoggedInException {
|
||||
if (!plugInPort.getCloudService().isLoggedIn())
|
||||
throw new NotLoggedInException();
|
||||
|
||||
@@ -129,13 +126,13 @@ public class ChatbotService {
|
||||
File aiProjectFile = getAiProjectFile();
|
||||
|
||||
try {
|
||||
String response = getService().promptChatbot(plugInPort.getCloudService().getCurrentUsername(),
|
||||
return getService().promptChatbot(
|
||||
plugInPort.getCloudService().getCurrentUsername(),
|
||||
plugInPort.getCloudService().getCurrentToken(),
|
||||
plugInPort.getCloudService().getMachineId(), fileName, aiProjectFile, prompt);
|
||||
return Optional.ofNullable(response).orElse(SERVER_ERROR_PLEASE_TRY_AGAIN);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Chatbot error", e);
|
||||
throw new CloudException(SERVER_ERROR_PLEASE_TRY_AGAIN);
|
||||
plugInPort.getCloudService().getMachineId(),
|
||||
fileName,
|
||||
aiProjectFile,
|
||||
prompt);
|
||||
} finally {
|
||||
// Clean up the temp file immediately after use
|
||||
if (aiProjectFile != null && aiProjectFile.exists()) {
|
||||
@@ -144,7 +141,7 @@ public class ChatbotService {
|
||||
}
|
||||
}
|
||||
|
||||
public String analyzeCircuit() throws NotLoggedInException, CloudException {
|
||||
public String analyzeCircuit() throws NotLoggedInException {
|
||||
if (!plugInPort.getCloudService().isLoggedIn())
|
||||
throw new NotLoggedInException();
|
||||
|
||||
@@ -159,15 +156,9 @@ public class ChatbotService {
|
||||
String jsonResult = getService().analyzeCircuit(plugInPort.getCloudService().getCurrentUsername(),
|
||||
plugInPort.getCloudService().getCurrentToken(),
|
||||
plugInPort.getCloudService().getMachineId(), fileName, aiProjectFile);
|
||||
|
||||
if (jsonResult == null || jsonResult.trim().isEmpty()) {
|
||||
throw new CloudException(SERVER_ERROR_PLEASE_TRY_AGAIN);
|
||||
}
|
||||
|
||||
return JsonToHtmlConverter.convertToHtml(jsonResult);
|
||||
} catch (Exception e) {
|
||||
LOG.error("AI Analyzer error", e);
|
||||
throw new CloudException(SERVER_ERROR_PLEASE_TRY_AGAIN);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
// Clean up the temp file immediately after use
|
||||
if (aiProjectFile != null && aiProjectFile.exists()) {
|
||||
@@ -197,7 +188,6 @@ public class ChatbotService {
|
||||
- Coordinates are represented in pixels assuming 200px/in resolution.
|
||||
- Each component will either have a set of terminals that are connectable to other components or one or two points defining its position.
|
||||
- Netlists of connected terminals are defined in the 'nets' structure.
|
||||
- Connective components (wires, jumpers, traces, etc) are not part of the netlist, they are there to understand physical diagram but their conductive properties are already taken into account when constructing the netlist
|
||||
- Analyze labels - they could provide clues about nearby terminals and what they represent.
|
||||
""");
|
||||
if (aiProject.switches() != null && !aiProject.switches().isEmpty()) {
|
||||
|
||||
-1
@@ -33,7 +33,6 @@ public class JsonToHtmlConverter {
|
||||
.append("</head>\n<body>\n");
|
||||
|
||||
// Process each section
|
||||
processSection(root, "analysis", html, "#008000");
|
||||
processSection(root, "critical", html, "#c00");
|
||||
processSection(root, "warnings", html, "#e65c00");
|
||||
processSection(root, "optimizations", html, "#0066c0");
|
||||
|
||||
@@ -86,8 +86,8 @@ public class CloudService {
|
||||
public CloudService(IPlugInPort plugInPort) {
|
||||
this.plugInPort = plugInPort;
|
||||
|
||||
serviceUrl = System.getProperty("org.diylc.cloud.baseUrl",
|
||||
ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1"));
|
||||
serviceUrl = ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY,
|
||||
"http://www.diy-fever.com/diylc/api/v1");
|
||||
ProxyFactory factory = new ProxyFactory(new PhpFlatProxy());
|
||||
service = factory.createProxy(IServiceAPI.class, serviceUrl);
|
||||
|
||||
@@ -104,6 +104,12 @@ public class CloudService {
|
||||
}
|
||||
|
||||
private IServiceAPI getService() {
|
||||
if (service == null) {
|
||||
serviceUrl =
|
||||
ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1");
|
||||
ProxyFactory factory = new ProxyFactory(new PhpFlatProxy());
|
||||
service = factory.createProxy(IServiceAPI.class, serviceUrl);
|
||||
}
|
||||
return service;
|
||||
}
|
||||
|
||||
|
||||
+269
-75
@@ -22,7 +22,6 @@
|
||||
package org.diylc.plugins.compare.service;
|
||||
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.DummyView;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.netlist.Group;
|
||||
@@ -34,15 +33,14 @@ import org.diylc.plugins.compare.model.ComponentDiff;
|
||||
import org.diylc.plugins.compare.model.CompareResults;
|
||||
import org.diylc.presenter.Presenter;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CompareService {
|
||||
|
||||
@@ -55,9 +53,6 @@ public class CompareService {
|
||||
public CompareResults compareWith(File file) {
|
||||
Presenter presenter = new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
|
||||
presenter.loadProjectFromFile(file.getAbsolutePath());
|
||||
|
||||
renderInMemory(presenter);
|
||||
|
||||
try {
|
||||
List<Netlist> otherNetlists = presenter.extractNetlists(false);
|
||||
List<Netlist> thisNetlists = plugInPort.extractNetlists(false);
|
||||
@@ -70,85 +65,284 @@ public class CompareService {
|
||||
}
|
||||
}
|
||||
|
||||
private void renderInMemory(Presenter presenter) {
|
||||
Dimension d = presenter.getCanvasDimensions(false, false);
|
||||
BufferedImage img = new BufferedImage(
|
||||
Math.max(1, d.width), Math.max(1, d.height), BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = img.createGraphics();
|
||||
presenter.draw(g2d, EnumSet.noneOf(DrawOption.class), null, null, null, null);
|
||||
g2d.dispose();
|
||||
}
|
||||
|
||||
public CompareResults compare(Netlist netlist1, Netlist netlist2) {
|
||||
Set<String> currentComponents = extractNetlistedComponents(netlist1);
|
||||
Set<String> targetComponents = extractNetlistedComponents(netlist2);
|
||||
|
||||
List<ComponentDiff> componentDiffs = new ArrayList<>();
|
||||
for (String name : currentComponents) {
|
||||
if (!targetComponents.contains(name)) {
|
||||
componentDiffs.add(new ComponentDiff(name, true));
|
||||
}
|
||||
}
|
||||
for (String name : targetComponents) {
|
||||
if (!currentComponents.contains(name)) {
|
||||
componentDiffs.add(new ComponentDiff(name, false));
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> currentConnections = extractConnections(netlist1);
|
||||
Set<String> targetConnections = extractConnections(netlist2);
|
||||
// Get all groups from both netlists
|
||||
Set<Group> groups1 = netlist1.getGroups();
|
||||
Set<Group> groups2 = netlist2.getGroups();
|
||||
|
||||
// Build lists of differences
|
||||
List<ConnectionDiff> connectionDiffs = new ArrayList<>();
|
||||
for (String conn : currentConnections) {
|
||||
if (!targetConnections.contains(conn)) {
|
||||
String[] parts = conn.split("\\|");
|
||||
if (targetComponents.contains(parts[0]) && targetComponents.contains(parts[2])) {
|
||||
connectionDiffs.add(new ConnectionDiff(parts[0], parts[1], parts[2], parts[3], true));
|
||||
Set<ComponentDiff> componentDiffs = new HashSet<>();
|
||||
Set<String> addedComponentNames = new HashSet<>();
|
||||
|
||||
// Helper to get a unique string for a node
|
||||
java.util.function.Function<Node, String> nodeKey = node ->
|
||||
node.getComponent().getName() + ":" + node.getComponent().getControlPointNodeName(node.getPointIndex());
|
||||
|
||||
// Get all component names from both netlists for existence check
|
||||
Set<String> netlist1Components = netlist1.getComponents().stream()
|
||||
.map(comp -> comp.getName())
|
||||
.collect(Collectors.toSet());
|
||||
Set<String> netlist2Components = netlist2.getComponents().stream()
|
||||
.map(comp -> comp.getName())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// For each group in netlist1, check if it exists in netlist2
|
||||
for (Group group1 : groups1) {
|
||||
boolean groupFound = false;
|
||||
for (Group group2 : groups2) {
|
||||
if (areGroupsEqual(group1, group2)) {
|
||||
groupFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String conn : targetConnections) {
|
||||
if (!currentConnections.contains(conn)) {
|
||||
String[] parts = conn.split("\\|");
|
||||
if (currentComponents.contains(parts[0]) && currentComponents.contains(parts[2])) {
|
||||
connectionDiffs.add(new ConnectionDiff(parts[0], parts[1], parts[2], parts[3], false));
|
||||
if (!groupFound) {
|
||||
// If group not found, check each component
|
||||
List<Node> nodes = new ArrayList<>(group1.getNodes());
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
Node node = nodes.get(i);
|
||||
String componentName = node.getComponent().getName();
|
||||
|
||||
// Check if this component exists in any group in netlist2
|
||||
boolean componentExistsInNetlist2 = false;
|
||||
for (Group group2 : groups2) {
|
||||
for (Node node2 : group2.getNodes()) {
|
||||
if (node2.getComponent().getName().equals(componentName)) {
|
||||
componentExistsInNetlist2 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (componentExistsInNetlist2) break;
|
||||
}
|
||||
|
||||
// Add component difference if it doesn't exist in any group in netlist2 and hasn't been added yet
|
||||
if (!componentExistsInNetlist2 && addedComponentNames.add(componentName)) {
|
||||
componentDiffs.add(new ComponentDiff(componentName, true));
|
||||
}
|
||||
|
||||
// Add connection differences for each pair of nodes
|
||||
for (int j = i + 1; j < nodes.size(); j++) {
|
||||
Node otherNode = nodes.get(j);
|
||||
connectionDiffs.add(new ConnectionDiff(
|
||||
node.getComponent().getName(),
|
||||
node.getComponent().getControlPointNodeName(node.getPointIndex()),
|
||||
otherNode.getComponent().getName(),
|
||||
otherNode.getComponent().getControlPointNodeName(otherNode.getPointIndex()),
|
||||
true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean matches = componentDiffs.isEmpty() && connectionDiffs.isEmpty();
|
||||
return new CompareResults(matches, connectionDiffs, componentDiffs);
|
||||
// For each group in netlist2, check if it exists in netlist1
|
||||
for (Group group2 : groups2) {
|
||||
boolean groupFound = false;
|
||||
for (Group group1 : groups1) {
|
||||
if (areGroupsEqual(group1, group2)) {
|
||||
groupFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!groupFound) {
|
||||
// If group not found, check each component
|
||||
List<Node> nodes = new ArrayList<>(group2.getNodes());
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
Node node = nodes.get(i);
|
||||
String componentName = node.getComponent().getName();
|
||||
|
||||
// Check if this component exists in any group in netlist1
|
||||
boolean componentExistsInNetlist1 = false;
|
||||
for (Group group1 : groups1) {
|
||||
for (Node node1 : group1.getNodes()) {
|
||||
if (node1.getComponent().getName().equals(componentName)) {
|
||||
componentExistsInNetlist1 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (componentExistsInNetlist1) break;
|
||||
}
|
||||
|
||||
// Add component difference if it doesn't exist in any group in netlist1 and hasn't been added yet
|
||||
if (!componentExistsInNetlist1 && addedComponentNames.add(componentName)) {
|
||||
componentDiffs.add(new ComponentDiff(componentName, false));
|
||||
}
|
||||
|
||||
// Add connection differences for each pair of nodes
|
||||
for (int j = i + 1; j < nodes.size(); j++) {
|
||||
Node otherNode = nodes.get(j);
|
||||
connectionDiffs.add(new ConnectionDiff(
|
||||
node.getComponent().getName(),
|
||||
node.getComponent().getControlPointNodeName(node.getPointIndex()),
|
||||
otherNode.getComponent().getName(),
|
||||
otherNode.getComponent().getControlPointNodeName(otherNode.getPointIndex()),
|
||||
false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try to resolve differences by flipping non-polarized components
|
||||
if (!connectionDiffs.isEmpty()) {
|
||||
// Find all non-polarized components that have nodes in different groups
|
||||
Map<String, List<Group>> componentGroups = new HashMap<>();
|
||||
for (Group group : groups1) {
|
||||
for (Node node : group.getNodes()) {
|
||||
if (!node.getComponent().isPolarized()) {
|
||||
componentGroups.computeIfAbsent(node.getComponent().getName(), k -> new ArrayList<>())
|
||||
.add(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try swapping nodes for each non-polarized component that appears in multiple groups
|
||||
for (Map.Entry<String, List<Group>> entry : componentGroups.entrySet()) {
|
||||
if (entry.getValue().size() >= 2) {
|
||||
String componentName = entry.getKey();
|
||||
List<Group> groupsWithComponent = entry.getValue();
|
||||
|
||||
// Get the nodes from the first two groups
|
||||
Group group1 = groupsWithComponent.get(0);
|
||||
Group group2 = groupsWithComponent.get(1);
|
||||
|
||||
Node node1 = group1.getNodes().stream()
|
||||
.filter(n -> n.getComponent().getName().equals(componentName))
|
||||
.findFirst()
|
||||
.get();
|
||||
Node node2 = group2.getNodes().stream()
|
||||
.filter(n -> n.getComponent().getName().equals(componentName))
|
||||
.findFirst()
|
||||
.get();
|
||||
|
||||
// Create new groups with swapped nodes
|
||||
Group newGroup1 = new Group();
|
||||
Group newGroup2 = new Group();
|
||||
|
||||
// Copy all nodes except the ones we're swapping
|
||||
for (Node n : group1.getNodes()) {
|
||||
if (!n.getComponent().getName().equals(componentName)) {
|
||||
newGroup1.getNodes().add(n);
|
||||
}
|
||||
}
|
||||
for (Node n : group2.getNodes()) {
|
||||
if (!n.getComponent().getName().equals(componentName)) {
|
||||
newGroup2.getNodes().add(n);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the swapped nodes
|
||||
newGroup1.getNodes().add(node2);
|
||||
newGroup2.getNodes().add(node1);
|
||||
|
||||
// Create a new set of groups with the swapped nodes
|
||||
Set<Group> newGroups1 = new HashSet<>(groups1);
|
||||
newGroups1.remove(group1);
|
||||
newGroups1.remove(group2);
|
||||
newGroups1.add(newGroup1);
|
||||
newGroups1.add(newGroup2);
|
||||
|
||||
// Check if this resolves ALL differences
|
||||
List<ConnectionDiff> newDiffs = new ArrayList<>();
|
||||
Set<ComponentDiff> newComponentDiffs = new HashSet<>();
|
||||
|
||||
// Check groups from netlist1 against netlist2
|
||||
for (Group g1 : newGroups1) {
|
||||
boolean groupFound = false;
|
||||
for (Group g2 : groups2) {
|
||||
if (areGroupsEqual(g1, g2)) {
|
||||
groupFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!groupFound) {
|
||||
// Add connection differences for this group
|
||||
List<Node> nodes = new ArrayList<>(g1.getNodes());
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
Node node = nodes.get(i);
|
||||
for (int j = i + 1; j < nodes.size(); j++) {
|
||||
Node otherNode = nodes.get(j);
|
||||
newDiffs.add(new ConnectionDiff(
|
||||
node.getComponent().getName(),
|
||||
node.getComponent().getControlPointNodeName(node.getPointIndex()),
|
||||
otherNode.getComponent().getName(),
|
||||
otherNode.getComponent().getControlPointNodeName(otherNode.getPointIndex()),
|
||||
true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check groups from netlist2 against netlist1
|
||||
for (Group g2 : groups2) {
|
||||
boolean groupFound = false;
|
||||
for (Group g1 : newGroups1) {
|
||||
if (areGroupsEqual(g1, g2)) {
|
||||
groupFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!groupFound) {
|
||||
// Add connection differences for this group
|
||||
List<Node> nodes = new ArrayList<>(g2.getNodes());
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
Node node = nodes.get(i);
|
||||
for (int j = i + 1; j < nodes.size(); j++) {
|
||||
Node otherNode = nodes.get(j);
|
||||
newDiffs.add(new ConnectionDiff(
|
||||
node.getComponent().getName(),
|
||||
node.getComponent().getControlPointNodeName(node.getPointIndex()),
|
||||
otherNode.getComponent().getName(),
|
||||
otherNode.getComponent().getControlPointNodeName(otherNode.getPointIndex()),
|
||||
false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this swap resolved all differences, use the new groups
|
||||
if (newDiffs.isEmpty() && newComponentDiffs.isEmpty()) {
|
||||
groups1 = newGroups1;
|
||||
connectionDiffs = new ArrayList<>();
|
||||
componentDiffs = new HashSet<>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (connectionDiffs.isEmpty() && componentDiffs.isEmpty()) {
|
||||
return new CompareResults(true, List.of(), List.of());
|
||||
}
|
||||
return new CompareResults(false, connectionDiffs, new ArrayList<>(componentDiffs));
|
||||
}
|
||||
|
||||
private Set<String> extractNetlistedComponents(Netlist netlist) {
|
||||
Set<String> names = new HashSet<>();
|
||||
for (Group group : netlist.getGroups()) {
|
||||
for (Node node : group.getNodes()) {
|
||||
names.add(node.getComponent().getName());
|
||||
}
|
||||
private boolean areGroupsEqual(Group group1, Group group2) {
|
||||
if (group1.getNodes().size() != group2.getNodes().size()) {
|
||||
return false;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
private Set<String> extractConnections(Netlist netlist) {
|
||||
Set<String> connections = new HashSet<>();
|
||||
for (Group group : netlist.getGroups()) {
|
||||
List<Node> nodes = new ArrayList<>(group.getNodes());
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
for (int j = i + 1; j < nodes.size(); j++) {
|
||||
connections.add(connectionKey(nodes.get(i), nodes.get(j)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return connections;
|
||||
}
|
||||
// Helper to get a unique string for a node
|
||||
java.util.function.Function<Node, String> nodeKey = node ->
|
||||
node.getComponent().getName() + ":" + node.getComponent().getControlPointNodeName(node.getPointIndex());
|
||||
|
||||
private String connectionKey(Node a, Node b) {
|
||||
String keyA = a.getComponent().getName() + "|" + a.getComponent().getControlPointNodeName(a.getPointIndex());
|
||||
String keyB = b.getComponent().getName() + "|" + b.getComponent().getControlPointNodeName(b.getPointIndex());
|
||||
if (keyA.compareTo(keyB) <= 0) {
|
||||
return keyA + "|" + keyB;
|
||||
// For polarized components, we need to check exact node order
|
||||
List<String> group1Keys = group1.getNodes().stream()
|
||||
.map(nodeKey)
|
||||
.collect(Collectors.toList());
|
||||
List<String> group2Keys = group2.getNodes().stream()
|
||||
.map(nodeKey)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// If any component in the group is polarized, we need exact order match
|
||||
boolean hasPolarizedComponent = group1.getNodes().stream()
|
||||
.anyMatch(node -> node.getComponent().isPolarized()) ||
|
||||
group2.getNodes().stream()
|
||||
.anyMatch(node -> node.getComponent().isPolarized());
|
||||
|
||||
if (hasPolarizedComponent) {
|
||||
return group1Keys.equals(group2Keys);
|
||||
}
|
||||
return keyB + "|" + keyA;
|
||||
|
||||
// For non-polarized components, we can use unordered comparison
|
||||
return new HashSet<>(group1Keys).equals(new HashSet<>(group2Keys));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,13 @@
|
||||
package org.diylc.presenter;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
|
||||
@@ -27,15 +32,11 @@ import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
import com.thoughtworks.xstream.security.AnyTypePermission;
|
||||
|
||||
import org.diylc.common.BlockInstantiationMode;
|
||||
import org.diylc.common.BuildingBlockPackage;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.IBlockProcessor;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.IBlockProcessor.InvalidBlockException;
|
||||
import org.diylc.components.composite.CompositeComponent;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.ISwitch;
|
||||
import org.diylc.serialization.ProjectFileManager;
|
||||
|
||||
public class BuildingBlockManager {
|
||||
@@ -123,30 +124,19 @@ public class BuildingBlockManager {
|
||||
return pkg.getBlocks().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mode {@link BlockInstantiationMode#GROUP} reproduces the original behavior: every
|
||||
* component is cloned individually, with a fresh project-unique name, ready to be
|
||||
* pasted as an auto-grouped set of independent components.
|
||||
* {@link BlockInstantiationMode#COMPOSITE} clones the components and wraps them in a
|
||||
* single {@link CompositeComponent}, returned as the only element of the result list.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<IDIYComponent<?>> loadBlock(String blockName,
|
||||
List<IDIYComponent<?>> existingComponents, BlockInstantiationMode mode)
|
||||
throws InvalidBlockException {
|
||||
LOG.debug(String.format("loadBlock(%s, %s)", blockName, mode));
|
||||
List<IDIYComponent<?>> existingComponents) throws InvalidBlockException {
|
||||
LOG.debug(String.format("loadBlock(%s)", blockName));
|
||||
Map<String, List<IDIYComponent<?>>> blocks = (Map<String, List<IDIYComponent<?>>>) configManager
|
||||
.readObject(IPlugInPort.BLOCKS_KEY, null);
|
||||
if (blocks == null)
|
||||
throw new InvalidBlockException();
|
||||
Collection<IDIYComponent<?>> components = blocks.get(blockName);
|
||||
if (components == null)
|
||||
throw new InvalidBlockException();
|
||||
// clear potential control point every time!
|
||||
instantiationManager.setPotentialControlPoint(null);
|
||||
|
||||
if (mode == BlockInstantiationMode.GROUP) {
|
||||
// clone components, each getting its own fresh, project-unique name and id
|
||||
if (blocks != null) {
|
||||
Collection<IDIYComponent<?>> components = blocks.get(blockName);
|
||||
if (components == null)
|
||||
throw new InvalidBlockException();
|
||||
// clear potential control point every time!
|
||||
instantiationManager.setPotentialControlPoint(null);
|
||||
// clone components
|
||||
List<IDIYComponent<?>> clones = new ArrayList<IDIYComponent<?>>();
|
||||
List<IDIYComponent<?>> testComponents = new ArrayList<IDIYComponent<?>>(existingComponents);
|
||||
for (IDIYComponent<?> c : components)
|
||||
@@ -155,49 +145,14 @@ public class BuildingBlockManager {
|
||||
clone.setName(instantiationManager.createUniqueName(ComponentProcessor.getInstance()
|
||||
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) clone.getClass()),
|
||||
testComponents));
|
||||
clone.setId(UUID.randomUUID());
|
||||
testComponents.add(clone);
|
||||
clones.add(clone);
|
||||
} catch (CloneNotSupportedException e) {
|
||||
LOG.error("Could not clone component: " + c);
|
||||
}
|
||||
return clones;
|
||||
}
|
||||
|
||||
// COMPOSITE mode: clone components keeping their saved names. Those names are namespaced
|
||||
// under the composite's own name in the netlist (e.g. "ARD1.PH1.3"), so running them through
|
||||
// createUniqueName against the whole project would produce meaningless drift and break
|
||||
// netlist labels between two instances of the same block.
|
||||
List<IDIYComponent<?>> childClones = new ArrayList<IDIYComponent<?>>();
|
||||
for (IDIYComponent<?> c : components) {
|
||||
try {
|
||||
IDIYComponent<?> clone = c.clone();
|
||||
clone.setId(UUID.randomUUID());
|
||||
childClones.add(clone);
|
||||
} catch (CloneNotSupportedException e) {
|
||||
LOG.error("Could not clone component: " + c);
|
||||
}
|
||||
// CompositeComponent does not implement ISwitch (see design decision D6): a switch placed
|
||||
// inside a composite still draws and exposes its terminals, but contributes no switching
|
||||
// behavior to the netlist. Flag it so this silent difference from group mode isn't a
|
||||
// surprise.
|
||||
if (c instanceof ISwitch) {
|
||||
LOG.warn(String.format(
|
||||
"Building block \"%s\" contains a switch (%s). Its switching behavior will not be "
|
||||
+ "reflected in the netlist when instantiated as a single component.",
|
||||
blockName, c.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
CompositeComponent composite = new CompositeComponent();
|
||||
composite.getChildComponents().addAll(childClones);
|
||||
composite.initBlockName(blockName);
|
||||
composite.setId(UUID.randomUUID());
|
||||
ComponentType compositeType =
|
||||
ComponentProcessor.getInstance().extractComponentTypeFrom(CompositeComponent.class);
|
||||
composite.setName(instantiationManager.createUniqueName(compositeType, existingComponents));
|
||||
|
||||
return Collections.singletonList((IDIYComponent<?>) composite);
|
||||
} else
|
||||
throw new InvalidBlockException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -246,11 +201,5 @@ public class BuildingBlockManager {
|
||||
blocks.remove(blockName);
|
||||
configManager.writeValue(IBlockProcessor.BLOCKS_KEY, blocks);
|
||||
}
|
||||
|
||||
// drop the block from the recently used list too, so it doesn't linger as a dead entry
|
||||
List<String> recent =
|
||||
(List<String>) configManager.readObject(IPlugInPort.RECENT_COMPONENTS_KEY, null);
|
||||
if (recent != null && recent.remove(IBlockProcessor.BLOCK_PREFIX + blockName))
|
||||
configManager.writeValue(IPlugInPort.RECENT_COMPONENTS_KEY, recent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.diylc.presenter;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.List;
|
||||
|
||||
@@ -72,54 +71,4 @@ public class CalcUtils {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the relative luminance (perceived brightness) of a color.
|
||||
* Uses the standard formula: L = 0.299*R + 0.587*G + 0.114*B
|
||||
*
|
||||
* @param color the color to calculate luminance for
|
||||
* @return the luminance value between 0 and 255
|
||||
*/
|
||||
public static double calculateLuminance(Color color) {
|
||||
if (color == null) {
|
||||
return 0.0;
|
||||
}
|
||||
return 0.299 * color.getRed() + 0.587 * color.getGreen() + 0.114 * color.getBlue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a color to monochrome (black or white) based on its luminance.
|
||||
* Colors with luminance below the threshold (128) are converted to black,
|
||||
* otherwise to white. The alpha channel is preserved if present.
|
||||
*
|
||||
* @param color the color to convert
|
||||
* @param threshold the luminance threshold (default 128 for middle gray)
|
||||
* @return black or white color, preserving alpha channel
|
||||
*/
|
||||
public static Color convertToMonochrome(Color color, double threshold) {
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
double luminance = calculateLuminance(color);
|
||||
// Use <= to handle edge case where luminance equals threshold (should be white)
|
||||
// Add small epsilon to account for floating point precision issues
|
||||
Color monochromeColor = (luminance < threshold - 1e-10) ? Color.BLACK : Color.WHITE;
|
||||
// Preserve alpha channel if present
|
||||
if (color.getAlpha() < 255) {
|
||||
monochromeColor = new Color(monochromeColor.getRed(), monochromeColor.getGreen(),
|
||||
monochromeColor.getBlue(), color.getAlpha());
|
||||
}
|
||||
return monochromeColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a color to monochrome (black or white) based on its luminance.
|
||||
* Uses the default threshold of 128 (middle gray).
|
||||
*
|
||||
* @param color the color to convert
|
||||
* @return black or white color, preserving alpha channel
|
||||
*/
|
||||
public static Color convertToMonochrome(Color color) {
|
||||
return convertToMonochrome(color, 128.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,6 @@ import java.awt.image.BufferedImage;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -39,7 +35,6 @@ import org.apache.log4j.Logger;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.components.composite.CompositeComponent;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
@@ -68,8 +63,6 @@ public class ComponentProcessor {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ComponentProcessor.class);
|
||||
|
||||
private static final boolean LOG_COMPONENT_TYPE_DETAILS = false;
|
||||
|
||||
private static ComponentProcessor instance;
|
||||
|
||||
private Map<String, List<PropertyWrapper>> propertyCache;
|
||||
@@ -114,7 +107,7 @@ public class ComponentProcessor {
|
||||
String keywordTag;
|
||||
List<String[]> datasheet = null;
|
||||
int datasheetCreationStepCount = 0;
|
||||
|
||||
|
||||
if (clazz.isAnnotationPresent(ComponentDescriptor.class)) {
|
||||
ComponentDescriptor annotation = clazz.getAnnotation(ComponentDescriptor.class);
|
||||
name = annotation.name();
|
||||
@@ -160,7 +153,7 @@ public class ComponentProcessor {
|
||||
}
|
||||
ComponentType componentType =
|
||||
new ComponentType(name, description, creationMethod, category, namePrefix, author, icon, clazz, zOrder,
|
||||
flexibleZOrder, bomPolicy, autoEdit, transformer, keywordPolicy, keywordTag, cacheDrawing, datasheet,
|
||||
flexibleZOrder, bomPolicy, autoEdit, transformer, keywordPolicy, keywordTag, cacheDrawing, datasheet,
|
||||
datasheetCreationStepCount);
|
||||
componentTypeMap.put(clazz.getName(), componentType);
|
||||
return componentType;
|
||||
@@ -226,18 +219,6 @@ public class ComponentProcessor {
|
||||
return cloneProperties(properties);
|
||||
}
|
||||
|
||||
private static String formatPropertyType(Class<?> type) {
|
||||
return type == null ? null : type.getSimpleName();
|
||||
}
|
||||
|
||||
private static List<String> getPossibleValues(Class<?> type) {
|
||||
if (type == null || !type.isEnum())
|
||||
return null;
|
||||
return Arrays.stream(type.getEnumConstants())
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<PropertyWrapper> cloneProperties(List<PropertyWrapper> properties) {
|
||||
List<PropertyWrapper> result = new ArrayList<PropertyWrapper>(properties.size());
|
||||
for (PropertyWrapper propertyWrapper : properties) {
|
||||
@@ -262,7 +243,6 @@ public class ComponentProcessor {
|
||||
Set<Class<?>> componentTypeClasses = null;
|
||||
try {
|
||||
componentTypeClasses = reflections.getTypesAnnotatedWith(ComponentDescriptor.class, false);
|
||||
List<Map<String, Object>> componentSnapshots = LOG_COMPONENT_TYPE_DETAILS ? new ArrayList<>() : null;
|
||||
|
||||
for (Class<?> clazz : componentTypeClasses) {
|
||||
if (!Modifier.isAbstract(clazz.getModifiers()) && IDIYComponent.class.isAssignableFrom(clazz)) {
|
||||
@@ -274,11 +254,6 @@ public class ComponentProcessor {
|
||||
// just to store in the cache
|
||||
ComponentProcessor.getInstance().extractProperties(clazz);
|
||||
|
||||
// types created only programmatically (e.g. CompositeComponent) don't belong in the
|
||||
// palette, but still need to go through extractProperties() above so the cache is warm
|
||||
if (clazz.getAnnotation(ComponentDescriptor.class).hiddenInPalette())
|
||||
continue;
|
||||
|
||||
List<ComponentType> nestedList;
|
||||
if (componentTypes.containsKey(componentType.getCategory())) {
|
||||
nestedList = componentTypes.get(componentType.getCategory());
|
||||
@@ -287,42 +262,6 @@ public class ComponentProcessor {
|
||||
componentTypes.put(componentType.getCategory(), nestedList);
|
||||
}
|
||||
nestedList.add(componentType);
|
||||
|
||||
if (LOG_COMPONENT_TYPE_DETAILS) {
|
||||
try {
|
||||
Map<String, Object> snapshot = new LinkedHashMap<>();
|
||||
snapshot.put("name", componentType.getName());
|
||||
snapshot.put("description", componentType.getDescription());
|
||||
snapshot.put("creationMethod", componentType.getCreationMethod());
|
||||
snapshot.put("category", componentType.getCategory());
|
||||
List<PropertyWrapper> props = propertyCache.get(clazz.getName());
|
||||
snapshot.put("properties", props != null ? props.stream()
|
||||
.map(p -> {
|
||||
Map<String, Object> prop = new LinkedHashMap<>();
|
||||
prop.put("name", p.getName());
|
||||
prop.put("type", formatPropertyType(p.getType()));
|
||||
List<String> possibleValues = getPossibleValues(p.getType());
|
||||
if (possibleValues != null) {
|
||||
prop.put("possibleValues", possibleValues);
|
||||
}
|
||||
return prop;
|
||||
})
|
||||
.collect(Collectors.toList()) : Collections.emptyList());
|
||||
componentSnapshots.add(snapshot);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Failed to log component type details for " + clazz.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (LOG_COMPONENT_TYPE_DETAILS && componentSnapshots != null && !componentSnapshots.isEmpty()) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||
LOG.info("Component types: " + mapper.writeValueAsString(componentSnapshots));
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Failed to log component types JSON", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,23 +367,6 @@ public class ComponentProcessor {
|
||||
return transformer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name that should represent the component's type to a human or to the AI, e.g. in
|
||||
* the BOM, the netlist report or the AI project description. For a
|
||||
* {@link CompositeComponent} this is the source building block's name (e.g.
|
||||
* "Arduino Uno") rather than the generic "Building Block" type name, since every
|
||||
* composite shares one {@link ComponentType} (see design decision D5 in
|
||||
* {@code docs/plans/composite-building-blocks.md}).
|
||||
*/
|
||||
public static String getDisplayTypeName(IDIYComponent<?> component, ComponentType type) {
|
||||
if (component instanceof CompositeComponent) {
|
||||
String blockName = ((CompositeComponent) component).getBlockName();
|
||||
if (blockName != null && !blockName.isEmpty())
|
||||
return blockName;
|
||||
}
|
||||
return type.getName();
|
||||
}
|
||||
|
||||
public static boolean hasStickyPoint(IDIYComponent<?> c) {
|
||||
for (int i = 0; i < c.getControlPointCount(); i++)
|
||||
if (c.isControlPointSticky(0))
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@@ -39,7 +38,7 @@ public class DatasheetService {
|
||||
|
||||
private static DatasheetService instance;
|
||||
|
||||
private static Map<String, List<String[]>> datasheetCache = new ConcurrentHashMap<>();
|
||||
private static Map<String, List<String[]>> datasheetCache = new HashMap<String, List<String[]>>();
|
||||
private static Map<String, Map<String, List<String[]>>> lookupCache =
|
||||
new HashMap<String, Map<String, List<String[]>>>();
|
||||
|
||||
|
||||
@@ -26,12 +26,10 @@ import java.lang.ref.SoftReference;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.core.ComponentForRender;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -69,14 +67,14 @@ public class DrawingCache {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void bulkPrepare(Collection<ComponentForRender> components, G2DWrapper g2d, boolean outlineMode, Project project,
|
||||
double zoom, double scaleFactor, Set<DrawOption> drawOptions) {
|
||||
double zoom, double scaleFactor) {
|
||||
// run all renders in parallel to utilize all CPU cores
|
||||
components.stream().parallel().forEach(x -> {
|
||||
ComponentType type = ComponentProcessor.getInstance()
|
||||
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) x.getComponent().getClass());
|
||||
|
||||
if (type != null && type.getEnableCache()) {
|
||||
renderAndCache(x.getComponent(), g2d, x.getState(), outlineMode, project, zoom, scaleFactor, x.getZOrder(), drawOptions);
|
||||
renderAndCache(x.getComponent(), g2d, x.getState(), outlineMode, project, zoom, scaleFactor, x.getZOrder());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -94,7 +92,7 @@ public class DrawingCache {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void draw(IDIYComponent<?> component, G2DWrapper g2d, ComponentState componentState,
|
||||
boolean outlineMode, Project project, double zoom, double scaleFactor, int zOrder, Rectangle2D visibleRect, Set<DrawOption> drawOptions) {
|
||||
boolean outlineMode, Project project, double zoom, double scaleFactor, int zOrder, Rectangle2D visibleRect) {
|
||||
ComponentType type = ComponentProcessor.getInstance()
|
||||
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass());
|
||||
|
||||
@@ -102,7 +100,7 @@ public class DrawingCache {
|
||||
// if we need to apply caching
|
||||
Point2D firstPoint = component.getControlPoint(0);
|
||||
|
||||
CacheValue value = renderAndCache(component, g2d, componentState, outlineMode, project, zoom, scaleFactor, zOrder, drawOptions);
|
||||
CacheValue value = renderAndCache(component, g2d, componentState, outlineMode, project, zoom, scaleFactor, zOrder);
|
||||
|
||||
if (value == null) {
|
||||
return;
|
||||
@@ -182,7 +180,7 @@ public class DrawingCache {
|
||||
}
|
||||
|
||||
private CacheValue renderAndCache(IDIYComponent<?> component, G2DWrapper g2d, ComponentState componentState,
|
||||
boolean outlineMode, Project project, double zoom, double scaleFactor, int zOrder, Set<DrawOption> drawOptions) {
|
||||
boolean outlineMode, Project project, double zoom, double scaleFactor, int zOrder) {
|
||||
|
||||
if (!g2d.getClipBounds().intersects(component.getCachingBounds())) {
|
||||
return null;
|
||||
@@ -201,11 +199,9 @@ public class DrawingCache {
|
||||
}
|
||||
|
||||
// only honor the cache if the component hasn't changed in the meantime
|
||||
// Also check if drawOptions changed (e.g., MONOCHROMATIC affects rendering)
|
||||
boolean drawOptionsChanged = value == null || !value.getDrawOptions().equals(drawOptions);
|
||||
if (value == null || !value.getComponent().equalsTo(component)
|
||||
|| value.getState() != componentState || value.getZoom() != zoom || value.getOutlineMode() != outlineMode
|
||||
|| value.getScaleFactor() != scaleFactor || drawOptionsChanged) {
|
||||
|| value.getScaleFactor() != scaleFactor) {
|
||||
// figure out size and placement of buffer image
|
||||
Rectangle2D rect = component.getCachingBounds();
|
||||
int width = (int)Math.round(rect.getWidth() * zoom);
|
||||
@@ -237,7 +233,7 @@ public class DrawingCache {
|
||||
cg2d.translate(-firstPoint.getX() + dx, -firstPoint.getY() + dy);
|
||||
|
||||
// wrap the graphics so we can track
|
||||
G2DWrapper wrapper = new G2DWrapper(cg2d, zoom, drawOptions);
|
||||
G2DWrapper wrapper = new G2DWrapper(cg2d, zoom);
|
||||
|
||||
// initialize wrapper
|
||||
wrapper.startedDrawingComponent(zOrder);
|
||||
@@ -279,7 +275,7 @@ public class DrawingCache {
|
||||
|
||||
// add to the cache
|
||||
value = new CacheValue(component, image, wrapper.getCurrentArea(), wrapper.getContinuityPositiveAreas(),
|
||||
wrapper.getContinuityNegativeAreas(), componentState, outlineMode, zoom, scaleFactor, dx, dy, rect, drawOptions);
|
||||
wrapper.getContinuityNegativeAreas(), componentState, outlineMode, zoom, scaleFactor, dx, dy, rect);
|
||||
imageCache.put(component, new SoftReference<DrawingCache.CacheValue>(value));
|
||||
}
|
||||
|
||||
@@ -299,12 +295,11 @@ public class DrawingCache {
|
||||
int dx;
|
||||
int dy;
|
||||
Rectangle2D cacheBounds;
|
||||
Set<DrawOption> drawOptions;
|
||||
|
||||
public CacheValue(IDIYComponent<?> component, BufferedImage image, Area currentArea,
|
||||
Map<String, Area> continuityPositiveAreas, Map<String, Area> continuityNegativeAreas,
|
||||
ComponentState state, boolean outlineMode, double zoom, double scaleFactor, int dx, int dy,
|
||||
Rectangle2D cacheBounds, Set<DrawOption> drawOptions) {
|
||||
Rectangle2D cacheBounds) {
|
||||
super();
|
||||
this.cacheBounds = cacheBounds;
|
||||
// take a copy of the component, so we can check if it changed in the meantime
|
||||
@@ -322,7 +317,6 @@ public class DrawingCache {
|
||||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
this.scaleFactor = scaleFactor;
|
||||
this.drawOptions = drawOptions;
|
||||
}
|
||||
|
||||
public IDIYComponent<?> getComponent() {
|
||||
@@ -372,10 +366,6 @@ public class DrawingCache {
|
||||
public Rectangle2D getCacheBounds() {
|
||||
return cacheBounds;
|
||||
}
|
||||
|
||||
public Set<DrawOption> getDrawOptions() {
|
||||
return drawOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -50,10 +50,10 @@ import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
|
||||
import org.diylc.common.*;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.*;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.filter.IComponentFilter;
|
||||
import org.diylc.netlist.ContinuityGraph;
|
||||
import org.diylc.netlist.NetlistBuilder;
|
||||
import org.diylc.utils.Constants;
|
||||
@@ -67,7 +67,7 @@ import org.diylc.utils.Constants;
|
||||
public class DrawingManager {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(DrawingManager.class);
|
||||
public static final Percentage MIRROR_ALPHA = new Percentage(50);
|
||||
public static final byte MIRROR_ALPHA = 64;
|
||||
|
||||
public static int CONTROL_POINT_SIZE = 7;
|
||||
public static double EXTRA_SPACE = 0.25;
|
||||
@@ -183,7 +183,7 @@ public class DrawingManager {
|
||||
if (externalZoom != null)
|
||||
zoom *= externalZoom;
|
||||
|
||||
G2DWrapper g2dWrapper = new G2DWrapper(g2d, zoom, drawOptions);
|
||||
G2DWrapper g2dWrapper = new G2DWrapper(g2d, zoom);
|
||||
|
||||
configureRenderingHints(g2d, drawOptions);
|
||||
|
||||
@@ -191,27 +191,19 @@ public class DrawingManager {
|
||||
Map<IBoard, List<IDIYComponent<?>>> boardMap = project.getComponents().stream()
|
||||
.filter(IBoard.class::isInstance)
|
||||
.map(IBoard.class::cast)
|
||||
.filter(b -> b.getUndersideDisplay() != null && b.getUndersideDisplay() != BoardUndersideDisplay.NONE)
|
||||
.filter(b -> b.getUndersideDisplay() != BoardUndersideDisplay.NONE)
|
||||
.collect(Collectors.toMap(x -> x, x -> new ArrayList<IDIYComponent<?>>()));
|
||||
Map<IDIYComponent<?>, Set<IBoard>> componentBoardMap = new HashMap<IDIYComponent<?>, Set<IBoard>>();
|
||||
|
||||
for (IBoard board : boardMap.keySet()) {
|
||||
Rectangle2D boardRect = board.getBoardRectangle();
|
||||
if (boardRect == null) {
|
||||
continue;
|
||||
}
|
||||
double minX = Math.min(boardRect.getMinX(), boardRect.getMaxX());
|
||||
double maxX = Math.max(boardRect.getMinX(), boardRect.getMaxX());
|
||||
double minY = Math.min(boardRect.getMinY(), boardRect.getMaxY());
|
||||
double maxY = Math.max(boardRect.getMinY(), boardRect.getMaxY());
|
||||
Rectangle2D normalizedBoardRect = new Rectangle2D.Double(minX, minY, maxX - minX, maxY - minY);
|
||||
for (IDIYComponent<?> c : project.getComponents()) {
|
||||
if (c == board) {
|
||||
continue;
|
||||
}
|
||||
boolean include = false;
|
||||
for (int i = 0; i < c.getControlPointCount(); i++) {
|
||||
if (normalizedBoardRect.contains(c.getControlPoint(i))) {
|
||||
if (boardRect.contains(c.getControlPoint(i))) {
|
||||
include = true;
|
||||
break;
|
||||
}
|
||||
@@ -275,7 +267,7 @@ public class DrawingManager {
|
||||
|
||||
// give the cache a chance to prepare all the components in multiple threads
|
||||
if (drawOptions.contains(DrawOption.ENABLE_CACHING)) {
|
||||
DrawingCache.Instance.bulkPrepare(componentForRenderList, g2dWrapper, outlineMode, project, zoom, scaleFactor, drawOptions);
|
||||
DrawingCache.Instance.bulkPrepare(componentForRenderList, g2dWrapper, outlineMode, project, zoom, scaleFactor);
|
||||
}
|
||||
|
||||
// componentAreaMap.clear();
|
||||
@@ -344,17 +336,26 @@ public class DrawingManager {
|
||||
try {
|
||||
// Mirror components that belong to boards that need to be mirrored
|
||||
if (componentBoardMap.containsKey(component)) {
|
||||
Set<IBoard> boards = componentBoardMap.get(component);
|
||||
for (IBoard board : boards) {
|
||||
drawMirroredComponent(project, board, component, g2dWrapper, state, outlineMode);
|
||||
@SuppressWarnings("unchecked")
|
||||
ComponentType componentType = ComponentProcessor.getInstance()
|
||||
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass());
|
||||
if (componentType.getTransformer() != null) {
|
||||
Set<IBoard> boards = componentBoardMap.get(component);
|
||||
for (IBoard board : boards) {
|
||||
drawMirroredComponent(project, board, component, componentType, g2dWrapper, state,
|
||||
outlineMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if a component itself is a board that needs to be mirrored, do it
|
||||
if (component instanceof IBoard) {
|
||||
IBoard board = (IBoard) component;
|
||||
if (board.getUndersideDisplay() != null && board.getUndersideDisplay() != BoardUndersideDisplay.NONE) {
|
||||
drawMirroredComponent(project, board, component, g2dWrapper, state, outlineMode);
|
||||
if (IBoard.class.isInstance(component) && componentBoardMap.values().stream()
|
||||
.anyMatch(boards -> boards.contains(component))) {
|
||||
ComponentType componentType = ComponentProcessor.getInstance()
|
||||
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass());
|
||||
if (componentType.getTransformer() != null) {
|
||||
drawMirroredComponent(project, (IBoard) component, component, componentType,
|
||||
g2dWrapper, state, outlineMode);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@@ -384,8 +385,8 @@ public class DrawingManager {
|
||||
g2dWrapper.setColor(CONTROL_POINT_COLOR);
|
||||
Point2D controlPoint = component.getControlPoint(i);
|
||||
int pointSize = CONTROL_POINT_SIZE - 2;
|
||||
g2dWrapper.fillOval((int) Math.round(controlPoint.getX() - pointSize / 2),
|
||||
(int) Math.round(controlPoint.getY() - pointSize / 2), pointSize, pointSize);
|
||||
g2dWrapper.fillOval((int) (controlPoint.getX() - pointSize / 2),
|
||||
(int) (controlPoint.getY() - pointSize / 2), pointSize, pointSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -401,11 +402,11 @@ public class DrawingManager {
|
||||
int pointSize = CONTROL_POINT_SIZE;
|
||||
|
||||
g2dWrapper.setColor(SELECTED_CONTROL_POINT_COLOR.darker());
|
||||
g2dWrapper.fillOval((int) Math.round(controlPoint.getX() - pointSize / 2),
|
||||
(int) Math.round(controlPoint.getY() - pointSize / 2), pointSize, pointSize);
|
||||
g2dWrapper.fillOval((int) (controlPoint.getX() - pointSize / 2),
|
||||
(int) (controlPoint.getY() - pointSize / 2), pointSize, pointSize);
|
||||
g2dWrapper.setColor(SELECTED_CONTROL_POINT_COLOR);
|
||||
g2dWrapper.fillOval((int) Math.round(controlPoint.getX() - CONTROL_POINT_SIZE / 2 + 1),
|
||||
(int) Math.round(controlPoint.getY() - CONTROL_POINT_SIZE / 2 + 1), CONTROL_POINT_SIZE - 2,
|
||||
g2dWrapper.fillOval((int) (controlPoint.getX() - CONTROL_POINT_SIZE / 2 + 1),
|
||||
(int) (controlPoint.getY() - CONTROL_POINT_SIZE / 2 + 1), CONTROL_POINT_SIZE - 2,
|
||||
CONTROL_POINT_SIZE - 2);
|
||||
}
|
||||
}
|
||||
@@ -435,12 +436,12 @@ public class DrawingManager {
|
||||
for (Point2D point : controlPointSlot) {
|
||||
if (point != null) {
|
||||
g2dWrapper.setColor(SELECTED_CONTROL_POINT_COLOR.darker());
|
||||
g2dWrapper.fillOval((int) Math.round(point.getX() - CONTROL_POINT_SIZE / 2),
|
||||
(int) Math.round(point.getY() - CONTROL_POINT_SIZE / 2), CONTROL_POINT_SIZE,
|
||||
g2dWrapper.fillOval((int) (point.getX() - CONTROL_POINT_SIZE / 2),
|
||||
(int) (point.getY() - CONTROL_POINT_SIZE / 2), CONTROL_POINT_SIZE,
|
||||
CONTROL_POINT_SIZE);
|
||||
g2dWrapper.setColor(SELECTED_CONTROL_POINT_COLOR);
|
||||
g2dWrapper.fillOval((int) Math.round(point.getX() - CONTROL_POINT_SIZE / 2 + 1),
|
||||
(int) Math.round(point.getY() - CONTROL_POINT_SIZE / 2 + 1), CONTROL_POINT_SIZE - 2,
|
||||
g2dWrapper.fillOval((int) (point.getX() - CONTROL_POINT_SIZE / 2 + 1),
|
||||
(int) (point.getY() - CONTROL_POINT_SIZE / 2 + 1), CONTROL_POINT_SIZE - 2,
|
||||
CONTROL_POINT_SIZE - 2);
|
||||
}
|
||||
}
|
||||
@@ -524,94 +525,46 @@ public class DrawingManager {
|
||||
}
|
||||
|
||||
private static void drawMirroredComponent(Project project, IBoard board, IDIYComponent<?> component,
|
||||
G2DWrapper g2dWrapper, ComponentState state, boolean outlineMode) {
|
||||
if (board.getUndersideDisplay() == null || board.getUndersideDisplay() == BoardUndersideDisplay.NONE) {
|
||||
return;
|
||||
}
|
||||
double offset = board.getUndersideOffset() == null ? 0 : board.getUndersideOffset().convertToPixels();
|
||||
ComponentType componentType, G2DWrapper g2dWrapper, ComponentState state, boolean outlineMode) {
|
||||
double offset = board.getUndersideOffset().convertToPixels();
|
||||
Rectangle2D boardRectangle = board.getBoardRectangle();
|
||||
if (boardRectangle == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
double minX = Math.min(boardRectangle.getMinX(), boardRectangle.getMaxX());
|
||||
double maxX = Math.max(boardRectangle.getMinX(), boardRectangle.getMaxX());
|
||||
double minY = Math.min(boardRectangle.getMinY(), boardRectangle.getMaxY());
|
||||
double maxY = Math.max(boardRectangle.getMinY(), boardRectangle.getMaxY());
|
||||
|
||||
AffineTransform mirrorTx = new AffineTransform();
|
||||
switch (board.getUndersideDisplay()) {
|
||||
case ABOVE: {
|
||||
double pivotY = minY - offset / 2;
|
||||
mirrorTx.translate(0, pivotY);
|
||||
mirrorTx.scale(1.0, -1.0);
|
||||
mirrorTx.translate(0, -pivotY);
|
||||
break;
|
||||
}
|
||||
case BELOW: {
|
||||
double pivotY = maxY + offset / 2;
|
||||
mirrorTx.translate(0, pivotY);
|
||||
mirrorTx.scale(1.0, -1.0);
|
||||
mirrorTx.translate(0, -pivotY);
|
||||
break;
|
||||
}
|
||||
case LEFT: {
|
||||
double pivotX = minX - offset / 2;
|
||||
mirrorTx.translate(pivotX, 0);
|
||||
mirrorTx.scale(-1.0, 1.0);
|
||||
mirrorTx.translate(-pivotX, 0);
|
||||
break;
|
||||
}
|
||||
case RIGHT: {
|
||||
double pivotX = maxX + offset / 2;
|
||||
mirrorTx.translate(pivotX, 0);
|
||||
mirrorTx.scale(-1.0, 1.0);
|
||||
mirrorTx.translate(-pivotX, 0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
G2DWrapper.MirrorDirection mirrorDirection;
|
||||
switch (board.getUndersideDisplay()) {
|
||||
case ABOVE:
|
||||
case BELOW:
|
||||
mirrorDirection = G2DWrapper.MirrorDirection.VERTICAL;
|
||||
break;
|
||||
case LEFT:
|
||||
case RIGHT:
|
||||
mirrorDirection = G2DWrapper.MirrorDirection.HORIZONTAL;
|
||||
break;
|
||||
default:
|
||||
mirrorDirection = G2DWrapper.MirrorDirection.NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
AffineTransform oldTx = g2dWrapper.getTransform();
|
||||
Composite oldComposite = g2dWrapper.getComposite();
|
||||
g2dWrapper.setMirrorDirection(mirrorDirection);
|
||||
try {
|
||||
g2dWrapper.transform(mirrorTx);
|
||||
if (Boolean.TRUE.equals(board.getUndersideTransparency())) {
|
||||
g2dWrapper.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(MIRROR_ALPHA.getValue().doubleValue() / 100d)));
|
||||
IDIYComponent<?> clonedComponent = component.clone();
|
||||
int direction = 0;
|
||||
Point2D pivotPoint = new Point2D.Double();
|
||||
switch (board.getUndersideDisplay()) {
|
||||
case ABOVE:
|
||||
direction = IComponentTransformer.VERTICAL;
|
||||
pivotPoint.setLocation(boardRectangle.getMinX(), boardRectangle.getMinY() - offset / 2);
|
||||
break;
|
||||
case BELOW:
|
||||
direction = IComponentTransformer.VERTICAL;
|
||||
pivotPoint.setLocation(boardRectangle.getMinX(), boardRectangle.getMaxY() + offset / 2);
|
||||
break;
|
||||
case LEFT:
|
||||
direction = IComponentTransformer.HORIZONTAL;
|
||||
pivotPoint.setLocation(boardRectangle.getMinX() - offset / 2, boardRectangle.getMinY());
|
||||
break;
|
||||
case RIGHT:
|
||||
direction = IComponentTransformer.HORIZONTAL;
|
||||
pivotPoint.setLocation(boardRectangle.getMaxX() + offset / 2, boardRectangle.getMinY());
|
||||
break;
|
||||
}
|
||||
componentType.getTransformer().mirror(clonedComponent, pivotPoint, direction);
|
||||
if (board.getUndersideTransparency() && AbstractTransparentComponent.class.isInstance(clonedComponent)) {
|
||||
AbstractTransparentComponent<?> transparentComponent = (AbstractTransparentComponent<?>) clonedComponent;
|
||||
transparentComponent.setAlpha(MIRROR_ALPHA);
|
||||
}
|
||||
component.draw(g2dWrapper, state, outlineMode, project, g2dWrapper);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error drawing mirrored " + component.getName(), e);
|
||||
} finally {
|
||||
g2dWrapper.setMirrorDirection(G2DWrapper.MirrorDirection.NONE);
|
||||
g2dWrapper.setTransform(oldTx);
|
||||
g2dWrapper.setComposite(oldComposite);
|
||||
clonedComponent.draw(g2dWrapper, state, outlineMode, project, g2dWrapper);
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawComponent(Project project, Set<DrawOption> drawOptions, Double scaleFactor,
|
||||
Rectangle2D visibleRect, IDIYComponent<?> component, G2DWrapper g2dWrapper, ComponentState state,
|
||||
double zoom, int i, boolean outlineMode) {
|
||||
private static void drawComponent(Project project, Set<DrawOption> drawOptions, Double scaleFactor, Rectangle2D visibleRect, IDIYComponent<?> component, G2DWrapper g2dWrapper, ComponentState state, double zoom, int i, boolean outlineMode) {
|
||||
if (drawOptions.contains(DrawOption.ENABLE_CACHING)) // go through the DrawingCache
|
||||
DrawingCache.Instance.draw(component, g2dWrapper, state,
|
||||
drawOptions.contains(DrawOption.OUTLINE_MODE), project, zoom, scaleFactor, i, visibleRect, drawOptions);
|
||||
drawOptions.contains(DrawOption.OUTLINE_MODE), project, zoom, scaleFactor, i, visibleRect);
|
||||
else // go straight to the wrapper
|
||||
component.draw(g2dWrapper, state, outlineMode, project, g2dWrapper);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.awt.Shape;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.font.TextLayout;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Arc2D;
|
||||
import java.awt.geom.Area;
|
||||
@@ -54,11 +53,17 @@ import java.awt.image.renderable.RenderableImage;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.ZoomableStroke;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -66,7 +71,7 @@ import org.diylc.core.IDrawingObserver;
|
||||
/**
|
||||
* {@link Graphics2D} wrapper that keeps track of all drawing actions and creates an {@link Area}
|
||||
* that corresponds to drawn objects. Before each component is drawn,
|
||||
* {@link #startedDrawingComponent(int)} should be called. After the component is drawn, area may be
|
||||
* {@link #startedDrawingComponent()} should be called. After the component is drawn, area may be
|
||||
* retrieved using {@link #finishedDrawingComponent()}. Graphics configuration (color, font, etc) is
|
||||
* reset between each two components.
|
||||
*
|
||||
@@ -91,9 +96,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
|
||||
private int uniqueCounter = 0;
|
||||
|
||||
private final Graphics2D canvasGraphics;
|
||||
private final Set<DrawOption> drawOptions;
|
||||
|
||||
private Graphics2D canvasGraphics;
|
||||
private Stroke originalStroke;
|
||||
private Color originalColor;
|
||||
private Composite originalComposite;
|
||||
@@ -107,25 +110,17 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
private String continuityMarker;
|
||||
private Shape lastShape;
|
||||
|
||||
public enum MirrorDirection {
|
||||
NONE, HORIZONTAL, VERTICAL
|
||||
}
|
||||
|
||||
private MirrorDirection mirrorDirection = MirrorDirection.NONE;
|
||||
|
||||
private double zoom;
|
||||
private int zOrder;
|
||||
|
||||
/**
|
||||
* Creates a wrapper around specified {@link Graphics2D} object.
|
||||
*
|
||||
*
|
||||
* @param canvasGraphics
|
||||
* @param drawOptions
|
||||
*/
|
||||
public G2DWrapper(Graphics2D canvasGraphics, double zoom, Set<DrawOption> drawOptions) {
|
||||
public G2DWrapper(Graphics2D canvasGraphics, double zoom) {
|
||||
super();
|
||||
this.canvasGraphics = canvasGraphics;
|
||||
this.drawOptions = drawOptions;
|
||||
String debugAreaPerformanceStr = System.getProperty(DEBUG_AREA_PERFORMANCE);
|
||||
debugAreaPerformance = "true".equalsIgnoreCase(debugAreaPerformanceStr);
|
||||
this.zoom = zoom;
|
||||
@@ -140,14 +135,6 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
return canvasGraphics;
|
||||
}
|
||||
|
||||
public void setMirrorDirection(MirrorDirection mirrorDirection) {
|
||||
this.mirrorDirection = mirrorDirection != null ? mirrorDirection : MirrorDirection.NONE;
|
||||
}
|
||||
|
||||
public MirrorDirection getMirrorDirection() {
|
||||
return mirrorDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the current area and caches canvas settings.
|
||||
*
|
||||
@@ -347,35 +334,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
|
||||
@Override
|
||||
public void drawGlyphVector(GlyphVector g, float x, float y) {
|
||||
if (g == null) {
|
||||
return;
|
||||
}
|
||||
if (mirrorDirection != MirrorDirection.NONE) {
|
||||
Rectangle2D bounds = g.getVisualBounds();
|
||||
double width = bounds.getWidth();
|
||||
double height = bounds.getHeight();
|
||||
AffineTransform oldTx = canvasGraphics.getTransform();
|
||||
AffineTransform flipTx = new AffineTransform();
|
||||
if (mirrorDirection == MirrorDirection.HORIZONTAL) {
|
||||
double cx = x + bounds.getX() + width / 2.0;
|
||||
flipTx.translate(cx, 0);
|
||||
flipTx.scale(-1.0, 1.0);
|
||||
flipTx.translate(-cx, 0);
|
||||
} else if (mirrorDirection == MirrorDirection.VERTICAL) {
|
||||
double cy = y + bounds.getY() + height / 2.0;
|
||||
flipTx.translate(0, cy);
|
||||
flipTx.scale(1.0, -1.0);
|
||||
flipTx.translate(0, -cy);
|
||||
}
|
||||
canvasGraphics.transform(flipTx);
|
||||
try {
|
||||
canvasGraphics.drawGlyphVector(g, x, y);
|
||||
} finally {
|
||||
canvasGraphics.setTransform(oldTx);
|
||||
}
|
||||
} else {
|
||||
canvasGraphics.drawGlyphVector(g, x, y);
|
||||
}
|
||||
canvasGraphics.drawGlyphVector(g, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -404,14 +363,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
|
||||
@Override
|
||||
public void drawString(String str, int x, int y) {
|
||||
if (str == null) {
|
||||
return;
|
||||
}
|
||||
if (mirrorDirection != MirrorDirection.NONE) {
|
||||
drawMirroredString(str, x, y);
|
||||
} else {
|
||||
canvasGraphics.drawString(str, x, y);
|
||||
}
|
||||
canvasGraphics.drawString(str, x, y);
|
||||
if (drawingComponent && trackingAllowed) {
|
||||
FontMetrics fontMetrics = canvasGraphics.getFontMetrics();
|
||||
Rectangle2D rect = fontMetrics.getStringBounds(str, canvasGraphics);
|
||||
@@ -426,14 +378,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
|
||||
@Override
|
||||
public void drawString(String str, float x, float y) {
|
||||
if (str == null) {
|
||||
return;
|
||||
}
|
||||
if (mirrorDirection != MirrorDirection.NONE) {
|
||||
drawMirroredString(str, x, y);
|
||||
} else {
|
||||
canvasGraphics.drawString(str, x, y);
|
||||
}
|
||||
canvasGraphics.drawString(str, x, y);
|
||||
if (drawingComponent && trackingAllowed) {
|
||||
FontMetrics fontMetrics = canvasGraphics.getFontMetrics();
|
||||
Rectangle2D rect = fontMetrics.getStringBounds(str, canvasGraphics);
|
||||
@@ -443,87 +388,14 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
|
||||
@Override
|
||||
public void drawString(AttributedCharacterIterator iterator, int x, int y) {
|
||||
if (iterator == null) {
|
||||
return;
|
||||
}
|
||||
if (mirrorDirection != MirrorDirection.NONE) {
|
||||
drawMirroredString(iterator, x, y);
|
||||
} else {
|
||||
canvasGraphics.drawString(iterator, x, y);
|
||||
}
|
||||
canvasGraphics.drawString(iterator, x, y);
|
||||
// FIXME: process map
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawString(AttributedCharacterIterator iterator, float x, float y) {
|
||||
if (iterator == null) {
|
||||
return;
|
||||
}
|
||||
if (mirrorDirection != MirrorDirection.NONE) {
|
||||
drawMirroredString(iterator, x, y);
|
||||
} else {
|
||||
canvasGraphics.drawString(iterator, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawMirroredString(String str, float x, float y) {
|
||||
FontMetrics fontMetrics = canvasGraphics.getFontMetrics();
|
||||
Rectangle2D rect = fontMetrics.getStringBounds(str, canvasGraphics);
|
||||
double width = rect.getWidth();
|
||||
double ascent = fontMetrics.getAscent();
|
||||
double descent = fontMetrics.getDescent();
|
||||
|
||||
AffineTransform oldTx = canvasGraphics.getTransform();
|
||||
AffineTransform flipTx = new AffineTransform();
|
||||
|
||||
if (mirrorDirection == MirrorDirection.HORIZONTAL) {
|
||||
double cx = x + width / 2.0;
|
||||
flipTx.translate(cx, 0);
|
||||
flipTx.scale(-1.0, 1.0);
|
||||
flipTx.translate(-cx, 0);
|
||||
} else if (mirrorDirection == MirrorDirection.VERTICAL) {
|
||||
double cy = y - (ascent - descent) / 2.0;
|
||||
flipTx.translate(0, cy);
|
||||
flipTx.scale(1.0, -1.0);
|
||||
flipTx.translate(0, -cy);
|
||||
}
|
||||
|
||||
canvasGraphics.transform(flipTx);
|
||||
try {
|
||||
canvasGraphics.drawString(str, x, y);
|
||||
} finally {
|
||||
canvasGraphics.setTransform(oldTx);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawMirroredString(AttributedCharacterIterator iterator, float x, float y) {
|
||||
FontRenderContext frc = canvasGraphics.getFontRenderContext();
|
||||
TextLayout layout = new TextLayout(iterator, frc);
|
||||
Rectangle2D bounds = layout.getBounds();
|
||||
double width = bounds.getWidth();
|
||||
double ascent = layout.getAscent();
|
||||
double descent = layout.getDescent();
|
||||
|
||||
AffineTransform oldTx = canvasGraphics.getTransform();
|
||||
AffineTransform flipTx = new AffineTransform();
|
||||
|
||||
if (mirrorDirection == MirrorDirection.HORIZONTAL) {
|
||||
double cx = x + width / 2.0;
|
||||
flipTx.translate(cx, 0);
|
||||
flipTx.scale(-1.0, 1.0);
|
||||
flipTx.translate(-cx, 0);
|
||||
} else if (mirrorDirection == MirrorDirection.VERTICAL) {
|
||||
double cy = y - (ascent - descent) / 2.0;
|
||||
flipTx.translate(0, cy);
|
||||
flipTx.scale(1.0, -1.0);
|
||||
flipTx.translate(0, -cy);
|
||||
}
|
||||
|
||||
canvasGraphics.transform(flipTx);
|
||||
try {
|
||||
canvasGraphics.drawString(iterator, x, y);
|
||||
} finally {
|
||||
canvasGraphics.setTransform(oldTx);
|
||||
}
|
||||
canvasGraphics.drawString(iterator, x, y);
|
||||
// FIXME: process map
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -610,9 +482,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
|
||||
@Override
|
||||
public void setComposite(Composite comp) {
|
||||
if (!drawOptions.contains(DrawOption.OUTLINE_MODE)) {
|
||||
canvasGraphics.setComposite(comp);
|
||||
}
|
||||
canvasGraphics.setComposite(comp);
|
||||
// FIXME: check this.
|
||||
}
|
||||
|
||||
@@ -888,11 +758,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
||||
|
||||
@Override
|
||||
public void setColor(Color c) {
|
||||
if (drawOptions.contains(DrawOption.MONOCHROMATIC) && c != null) {
|
||||
canvasGraphics.setColor(CalcUtils.convertToMonochrome(c));
|
||||
} else {
|
||||
canvasGraphics.setColor(c);
|
||||
}
|
||||
canvasGraphics.setColor(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,13 @@ package org.diylc.presenter;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
@@ -34,7 +40,6 @@ import org.diylc.clipboard.ComponentTransferable;
|
||||
import org.diylc.common.*;
|
||||
|
||||
import org.diylc.core.Angle;
|
||||
import org.diylc.core.ComponentGroup;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
@@ -63,9 +68,9 @@ public class InstantiationManager {
|
||||
public static final ComponentType clipboardType = new ComponentType("Clipboard contents",
|
||||
"Components from the clipboard", CreationMethod.SINGLE_CLICK, "Multi", "", "", null, null, 0, false, null,
|
||||
false, null, KeywordPolicy.NEVER_SHOW, null, false, null, 0);
|
||||
// public static final ComponentType blockType = new ComponentType("Building block",
|
||||
// "Components from the building block", CreationMethod.SINGLE_CLICK, "Multi", "", "", null, null, 0, false, null,
|
||||
// false, null, KeywordPolicy.NEVER_SHOW, null, false, null, 0);
|
||||
public static final ComponentType blockType = new ComponentType("Building block",
|
||||
"Components from the building block", CreationMethod.SINGLE_CLICK, "Multi", "", "", null, null, 0, false, null,
|
||||
false, null, KeywordPolicy.NEVER_SHOW, null, false, null, 0);
|
||||
|
||||
public InstantiationManager() {}
|
||||
|
||||
@@ -208,10 +213,7 @@ public class InstantiationManager {
|
||||
|
||||
// Update the component type slot so the app knows that something's
|
||||
// being instantiated.
|
||||
String slotName = Optional.ofNullable(componentTransferable.getName()).orElse("Building Block");
|
||||
this.componentTypeSlot = autoGroup ? new ComponentType(slotName,
|
||||
"Components from the building block", CreationMethod.SINGLE_CLICK, "Multi", "", "", null, null, 0, false, null,
|
||||
false, null, KeywordPolicy.NEVER_SHOW, null, false, null, 0) : clipboardType;
|
||||
this.componentTypeSlot = autoGroup ? blockType : clipboardType;
|
||||
|
||||
if (snapToGrid) {
|
||||
scaledPoint = new Point2D.Double(scaledPoint.getX(), scaledPoint.getY());
|
||||
@@ -220,14 +222,9 @@ public class InstantiationManager {
|
||||
// Update the location according to mouse location
|
||||
updateSingleClick(scaledPoint, snapToGrid, gridSpacing);
|
||||
|
||||
// copy group information if available, but filter out invalid groups
|
||||
// copy group information if available
|
||||
if (componentTransferable.getGroups() != null) {
|
||||
for (ComponentGroup group : componentTransferable.getGroups()) {
|
||||
if (group.getComponentIds() != null && !group.getComponentIds().isEmpty() &&
|
||||
group.getComponentIds().stream().anyMatch(id -> id != null)) {
|
||||
currentProject.getGroupsEx().add(group);
|
||||
}
|
||||
}
|
||||
currentProject.getGroups().addAll(componentTransferable.getGroups());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,36 +269,11 @@ public class InstantiationManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes an identifier to the front of the recently used list, removing any earlier occurrence
|
||||
* and trimming the list to {@link #MAX_RECENT_COMPONENTS}. If the identifier is already at the
|
||||
* front nothing is written. The identifier is either a fully qualified component class name or a
|
||||
* building block reference of the form {@code "block:<blockName>"} (see
|
||||
* {@link IBlockProcessor#BLOCK_PREFIX}).
|
||||
*
|
||||
* @param identifier component class name or {@code "block:<blockName>"}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addToRecentComponents(String identifier) {
|
||||
List<String> recent = (List<String>) ConfigurationManager.getInstance()
|
||||
.readObject(IPlugInPort.RECENT_COMPONENTS_KEY, new ArrayList<String>());
|
||||
if (!recent.isEmpty() && recent.get(0).equals(identifier))
|
||||
return;
|
||||
// Remove if it's already somewhere in the list.
|
||||
recent.remove(identifier);
|
||||
// Add to the front of the list.
|
||||
recent.add(0, identifier);
|
||||
// Trim the list if necessary.
|
||||
while (recent.size() > MAX_RECENT_COMPONENTS)
|
||||
recent.remove(recent.size() - 1);
|
||||
ConfigurationManager.getInstance().writeValue(IPlugInPort.RECENT_COMPONENTS_KEY, recent);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<IDIYComponent<?>> instantiateComponent(ComponentType componentType, Point2D point,
|
||||
Project currentProject) throws InstantiationException, IllegalAccessException, NoSuchMethodException,
|
||||
SecurityException, IllegalArgumentException, InvocationTargetException {
|
||||
LOG.info("Instantiating component of type: " + componentType.getInstanceClass().getName());
|
||||
LOG.info("Instatiating component of type: " + componentType.getInstanceClass().getName());
|
||||
|
||||
// Instantiate the component.
|
||||
IDIYComponent<?> component;
|
||||
@@ -336,7 +308,21 @@ public class InstantiationManager {
|
||||
}
|
||||
|
||||
// Write to recent components
|
||||
addToRecentComponents(componentType.getInstanceClass().getName());
|
||||
List<String> recentComponentTypes =
|
||||
(List<String>) ConfigurationManager.getInstance().readObject(IPlugInPort.RECENT_COMPONENTS_KEY,
|
||||
new ArrayList<ComponentType>());
|
||||
String className = componentType.getInstanceClass().getName();
|
||||
if (recentComponentTypes.size() == 0 || !recentComponentTypes.get(0).equals(className)) {
|
||||
// Remove if it's already somewhere in the list.
|
||||
recentComponentTypes.remove(className);
|
||||
// Add to the end of the list.
|
||||
recentComponentTypes.add(0, className);
|
||||
// Trim the list if necessary.
|
||||
if (recentComponentTypes.size() > MAX_RECENT_COMPONENTS) {
|
||||
recentComponentTypes.remove(recentComponentTypes.size() - 1);
|
||||
}
|
||||
ConfigurationManager.getInstance().writeValue(IPlugInPort.RECENT_COMPONENTS_KEY, recentComponentTypes);
|
||||
}
|
||||
|
||||
List<IDIYComponent<?>> list = new ArrayList<IDIYComponent<?>>();
|
||||
list.add(component);
|
||||
|
||||
+2
-1
@@ -19,10 +19,11 @@
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.filter;
|
||||
package org.diylc.presenter;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.diylc.common.IComponentFilter;
|
||||
import org.diylc.common.PCBLayer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,131 +0,0 @@
|
||||
You are helping me generate Appendix A ? Component Model Reference for an ebook about DIY Layout Creator (DIYLC).
|
||||
|
||||
I will provide you with a JSON file that defines all component types used by DIYLC.
|
||||
|
||||
Your task
|
||||
|
||||
Convert the JSON into a single DOCX appendix that documents all components defined in the JSON, with no omissions and no inferred or invented information.
|
||||
|
||||
Structure rules (must follow exactly)
|
||||
1. Document structure
|
||||
|
||||
Output format: DOCX
|
||||
|
||||
Document title (H1):
|
||||
Appendix A ? Component Model Reference
|
||||
|
||||
Group components by category
|
||||
|
||||
Each category is an H2 heading
|
||||
|
||||
Category order: alphabetical
|
||||
|
||||
Component order within category: alphabetical
|
||||
|
||||
2. Component entry format
|
||||
|
||||
Do NOT use H3 or any heading for component names.
|
||||
|
||||
For each component, render the following:
|
||||
|
||||
Component Name (bold, normal paragraph)
|
||||
Description: <exact description text from JSON>
|
||||
Creation method: <human-friendly label>
|
||||
|
||||
|
||||
Creation method mapping:
|
||||
|
||||
POINT_BY_POINT ? Point-by-point
|
||||
|
||||
SINGLE_CLICK ? Single-click
|
||||
|
||||
Missing value ? (not specified)
|
||||
|
||||
3. Properties table
|
||||
|
||||
If the component defines properties, render a table immediately after the metadata:
|
||||
|
||||
| Property | Type | Possible values |
|
||||
|
||||
Table formatting requirements:
|
||||
|
||||
No visible borders (markdown-style look)
|
||||
|
||||
Column widths:
|
||||
|
||||
Property: 30%
|
||||
|
||||
Type: 30%
|
||||
|
||||
Possible values: 40%
|
||||
|
||||
Header row:
|
||||
|
||||
Bold text
|
||||
|
||||
Very light gray background (#EEEEEE)
|
||||
|
||||
Data rows:
|
||||
|
||||
Alternating row background
|
||||
|
||||
Very very light gray (#F7F7F7) on every second row
|
||||
|
||||
Row height:
|
||||
|
||||
As compact as possible
|
||||
|
||||
No extra vertical padding
|
||||
|
||||
Content rules:
|
||||
|
||||
Property name ? JSON name
|
||||
|
||||
Type ? JSON type
|
||||
|
||||
Possible values:
|
||||
|
||||
Populate only if the JSON defines an enum/list
|
||||
|
||||
Leave empty otherwise
|
||||
|
||||
If a component has no properties, write:
|
||||
|
||||
This component has no configurable properties.
|
||||
|
||||
4. Styling consistency
|
||||
|
||||
Font: Calibri
|
||||
|
||||
Base text size: 11 pt
|
||||
|
||||
Match the visual style of previously generated ebook chapters
|
||||
|
||||
No decorative elements
|
||||
|
||||
Clean, technical, reference-style layout
|
||||
|
||||
Strict constraints
|
||||
|
||||
? Do NOT summarize components
|
||||
|
||||
? Do NOT invent descriptions, properties, or values
|
||||
|
||||
? Do NOT rename properties or types
|
||||
|
||||
? Do NOT add commentary or interpretation
|
||||
|
||||
? Do NOT introduce additional columns
|
||||
|
||||
Everything must come directly from the JSON.
|
||||
|
||||
Final output
|
||||
|
||||
Produce one DOCX file
|
||||
|
||||
File name:
|
||||
Appendix A ? Component Model Reference.docx
|
||||
|
||||
When finished, provide a download link to the DOCX file.
|
||||
|
||||
Acknowledge when you are ready to receive the JSON file.
|
||||
@@ -32,8 +32,6 @@ import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
|
||||
import org.diylc.utils.MathUtils;
|
||||
|
||||
/**
|
||||
* Serializes {@link Area} objects by converting coordinates from pixels to inches, thus avoiding
|
||||
* the resolution to affect point placement.
|
||||
@@ -68,7 +66,7 @@ public class AreaConverter implements Converter {
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
writer.startNode("coordinate");
|
||||
writer.setValue(MathUtils.formatDouble(coord[i]));
|
||||
writer.setValue(String.valueOf(coord[i]));
|
||||
writer.endNode();
|
||||
}
|
||||
writer.endNode();
|
||||
@@ -89,7 +87,7 @@ public class AreaConverter implements Converter {
|
||||
List<java.lang.Double> values = new ArrayList<java.lang.Double>();
|
||||
while (reader.hasMoreChildren()) {
|
||||
reader.moveDown();
|
||||
values.add(MathUtils.parseDouble(reader.getValue()));
|
||||
values.add(java.lang.Double.parseDouble(reader.getValue()));
|
||||
reader.moveUp();
|
||||
}
|
||||
java.lang.Double[] coord = values.toArray(new java.lang.Double[0]);
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
|
||||
import org.diylc.utils.Constants;
|
||||
import org.diylc.utils.MathUtils;
|
||||
|
||||
/**
|
||||
* Serializes {@link Point2D} objects by converting coordinates from pixels to inches, thus avoiding
|
||||
@@ -43,27 +42,26 @@ public class PointConverter implements Converter {
|
||||
@Override
|
||||
public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext context) {
|
||||
Point2D point = (Point2D) object;
|
||||
writer.addAttribute("x", MathUtils.formatDouble(1d * point.getX() / Constants.PIXELS_PER_INCH));
|
||||
writer.addAttribute("y", MathUtils.formatDouble(1d * point.getY() / Constants.PIXELS_PER_INCH));
|
||||
writer.addAttribute("x", Double.toString(1d * point.getX() / Constants.PIXELS_PER_INCH));
|
||||
writer.addAttribute("y", Double.toString(1d * point.getY() / Constants.PIXELS_PER_INCH));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
|
||||
double x;
|
||||
double y;
|
||||
if (reader.hasMoreChildren()) {
|
||||
reader.moveDown();
|
||||
x = MathUtils.parseDouble(reader.getValue());
|
||||
x = Double.parseDouble(reader.getValue());
|
||||
reader.moveUp();
|
||||
reader.moveDown();
|
||||
y = MathUtils.parseDouble(reader.getValue());
|
||||
y = Double.parseDouble(reader.getValue());
|
||||
reader.moveUp();
|
||||
return new Point2D.Double(x, y);
|
||||
} else {
|
||||
x = MathUtils.round(Double.parseDouble(reader.getAttribute("x")) * Constants.PIXELS_PER_INCH);
|
||||
y = MathUtils.round(Double.parseDouble(reader.getAttribute("y")) * Constants.PIXELS_PER_INCH);
|
||||
return new Point2D.Double(x, y);
|
||||
x = Double.parseDouble(reader.getAttribute("x"));
|
||||
y = Double.parseDouble(reader.getAttribute("y"));
|
||||
return new Point2D.Double(x * Constants.PIXELS_PER_INCH, y * Constants.PIXELS_PER_INCH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
@@ -55,7 +54,6 @@ import com.thoughtworks.xstream.mapper.MapperWrapper;
|
||||
import com.thoughtworks.xstream.security.AnyTypePermission;
|
||||
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.test.DIYTest;
|
||||
@@ -114,7 +112,6 @@ public class ProjectFileManager {
|
||||
xStream.autodetectAnnotations(true);
|
||||
xStream.alias("point", java.awt.geom.Point2D.class);
|
||||
xStream.alias("point", java.awt.geom.Point2D.Double.class);
|
||||
xStream.alias("group", org.diylc.core.ComponentGroup.class);
|
||||
xStream.alias("font", java.awt.Font.class);
|
||||
xStream.alias("project", Project.class);
|
||||
xStream.aliasPackage("diylc", "org.diylc.components");
|
||||
@@ -281,29 +278,9 @@ public class ProjectFileManager {
|
||||
LOG.warn("The opened file is missing the following properties: " + String.join(", ", missingFields));
|
||||
warnings.add("The project references unknown component properties, most likely because it was created with a newer version of DIYLC.");
|
||||
}
|
||||
ensureUniqueComponentIds(project);
|
||||
fis.close();
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures no two components share the same identifier. Assigns a new UUID to any
|
||||
* component that has a null id or an id already seen (duplicate).
|
||||
*/
|
||||
private void ensureUniqueComponentIds(Project project) {
|
||||
if (project == null || project.getComponents() == null) {
|
||||
return;
|
||||
}
|
||||
Set<UUID> seenIds = new HashSet<UUID>();
|
||||
for (IDIYComponent<?> component : project.getComponents()) {
|
||||
UUID id = component.getId();
|
||||
if (id == null || seenIds.contains(id)) {
|
||||
component.setId(UUID.randomUUID());
|
||||
LOG.warn("Detected duplicated componentId: " + id);
|
||||
}
|
||||
seenIds.add(component.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private VersionNumber readV3Version(String fileName) throws Exception {
|
||||
File fXmlFile = new File(fileName);
|
||||
|
||||
@@ -81,7 +81,6 @@ public class BomMaker {
|
||||
(Class<? extends IDIYComponent<?>>) component.getClass());
|
||||
if (type.getBomPolicy() == BomPolicy.NEVER_SHOW)
|
||||
continue;
|
||||
String typeName = ComponentProcessor.getDisplayTypeName(component, type);
|
||||
String name = component.getName();
|
||||
String value;
|
||||
try {
|
||||
@@ -90,7 +89,7 @@ public class BomMaker {
|
||||
value = "<undefined>";
|
||||
}
|
||||
if ((name != null) && (value != null)) {
|
||||
String key = typeName + "|" + value;
|
||||
String key = type.getName() + "|" + value;
|
||||
if (entryMap.containsKey(key)) {
|
||||
BomEntry entry = entryMap.get(key);
|
||||
entry.setQuantity(entry.getQuantity() + 1);
|
||||
@@ -99,7 +98,7 @@ public class BomMaker {
|
||||
}
|
||||
} else {
|
||||
entryMap.put(key,
|
||||
new BomEntry(typeName, type.getBomPolicy() == BomPolicy.SHOW_ALL_NAMES ? name : typeName,
|
||||
new BomEntry(type.getName(), type.getBomPolicy() == BomPolicy.SHOW_ALL_NAMES ? name : type.getName(),
|
||||
value, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.utils;
|
||||
|
||||
public class MathUtils {
|
||||
|
||||
public static String formatDouble(double value) {
|
||||
return Double.toString(Math.round(value * 1e8) / 1e8);
|
||||
}
|
||||
|
||||
public static Double round(double value) {
|
||||
return Math.round(value * 1e8) / 1e8;
|
||||
}
|
||||
|
||||
public static double parseDouble(String str) {
|
||||
return Math.round(Double.parseDouble(str) * 1e8) / 1e8;
|
||||
}
|
||||
}
|
||||
@@ -46,8 +46,8 @@ public class VersionReader {
|
||||
sbHtml.append(" </release>\n");
|
||||
|
||||
System.out.println(sbMd.toString());
|
||||
// System.out.println();
|
||||
// System.out.println(sbHtml.toString());
|
||||
System.out.println();
|
||||
System.out.println(sbHtml.toString());
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,32 +2,20 @@
|
||||
<a class="org.diylc.appframework.update.Version-array">
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>10</minor>
|
||||
<build>0</build>
|
||||
<major>4</major>
|
||||
<minor>41</minor>
|
||||
<build>1</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-01-20 00:00:00.000 CET</releaseDate>
|
||||
<releaseDate>2025-03-08 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'M' and 'N' potentiometer taper options (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added E-C-B BJT pinout to TO-92 transistor package</description>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Do not mirror bottom layers for Gerber export as fabrication service providers expect a top view for everything</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed the performance issue that happens when groups of components are copy-pasted and the project size grows uncontrollably</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>All building blocks of the same type get added to the same group</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Tactile Micro Switch' editor doesn't show up on double click</description>
|
||||
<description>Selecting components by drawing a rectangle around them works glitchy</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
@@ -35,379 +23,415 @@
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>11</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-02-15 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added ability to export chat history from 'AI Assistant' to a HTML file</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Upgraded AI models for AI-powered tools and improved overall quality of the responses</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Windows installer prompts for installation folder instead of forcing one</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Shape components shouldn't appear in the BOM</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved rendering of 'Switch (Latching)' symbol to clearly make visual contact between the terminals</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Consolidate a few keyboard shortcuts for consistency</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Using "Duplicate Selection" results in duplicates of component ids, breaking Project Explorer panel and causing other issues downstream</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Calculated length disappeared from Hookup Wire and similar curved components</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Resize dimensions do not show for 'Chassis Panel' component when dragging a corner point</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>12</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-03-26 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Auto-Unit Conversion' configuration which automatically converts between metric and imperial units based on the ruler unit preference</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added a new section in the output of 'AI Circuit Analyzer' which provides insights into the operation of the circuit and individual components</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Better error handling for AI tools</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Pressing the 'Esc' key closes selection editor dialog</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Right click (or two finger tap on mac) after selecting a component with a regular click opens editor dialog in addition to the context menu</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Clicking on a component type in the left-hand component tree sometimes does not register and does not instantiate the component</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>13</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-04-07 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added new 'Heat Sink Resistor' component with a bunch of factory variants covering the most common types</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added new 'Dial Scale' variations - 'Ticks + Numeric (0/5.5/11)' a'la Friedman and another variation of 'Ticks' with more pronounced 9/12/3 o'clock indices</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Core' property to 'Radial Inductor' component that allows selection between Ferrite and Air core inductor models'</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Envelope' property to tube symbol components which can be used to display one side of the outer envelope dashed indicating section A or section B of a tube</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added more ceramic resistor variants to 'Resistor' component</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Uniformized rendering of components while being dragged</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Ability to blank-out previously populated values for unit-type measures, e.g. resistance, capacitance, dimensions, etc</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved data model for storing transparency alpha and other properties that are edited using a slider widget; as a result, the editing is more precise and does not randomly change to neighboring values</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved editing experience of integer properties (e.g. number of terminals on a tag strip) by using the spinner text field</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved logic when moving component(s) that have other components stuck with them; in case there are non-sticky control points within the included components, they will be moved along retaining component shape (e.g. wires or curved traces)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Decommission 'Loadline Editor' option from the File menu</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>14</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-06-03 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Potentiometer (Miniature)' component with two variations - right-angled and vertically mounted</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Thonk 3.5mm Jack' component with two variations - mono switched and stereo</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Enable all types of potentiometers and jacks for guitar diagram analysis</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Increase maximum number of switch combination for analysis to 1024</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>'Line' component set to px used to render slightly thicker than 1px, appearing thicker than schematic symbols; changed to match the thickenss of schematic symbols</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>15</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-06-13 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Add Freeway Blade switches 3B3-01, 5B5-01, 5B5-02 (thank you Martin Morell)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>IEC variations of fuse and potentiometer symbols</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Detect the style of a treble bleed based on the topology and component values (e.g. Fender, DiMarzio, Kinman, etc)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved quality of AI Assistant responses in some cases</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved precision of rendering, in some cases there was a sub-pixel misalignment between the lines that should meet exactly</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Tone capacitor mistaken for treble bleed when connected to the input lug of the volume pot</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Dragging a component from the component tree to the canvas sometimes does not work as expected without clicking on it first and then dragging it</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Schaller Megaswitch' not rendered correctly when rotated for 90 or 270 degrees</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>6</major>
|
||||
<minor>0</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-06-13 00:00:00.000 CET</releaseDate>
|
||||
<releaseDate>2025-03-09 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Upgrade Java version to 21</description>
|
||||
<description>Switched to AppImage distribution for Linux system, abandoning Flatpak as a means of distribution. DIYLC AppImage will be available alongside with other executables on the official DIYLC GitHub page.</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Upgraded Windows installer version and Windows EXE launcher version</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed scaling for 'Image' and 'SVG Image' components; it was showing as unrecognized</description>
|
||||
<description>Fixed alignment issues of round elements (e.g. solder pads and holes) in exported Gerber files</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed errors while analyzing guitar wiring diagrams caused by treble bleed enhancements</description>
|
||||
<description>Fixed the issue with opening DIY files on Mac OS</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>6</major>
|
||||
<major>5</major>
|
||||
<minor>1</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-06-30 00:00:00.000 CET</releaseDate>
|
||||
<releaseDate>2025-03-24 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added ability to render the underside of boards along with the top side for easier validation, building and debugging</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Configurable 'High DPI Rendering' feature which makes the diagram smoother on high-resolution displays but can affect performance</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved handling of larger AI analysis requests and added more token budget per request to Supporter and Pro plans</description>
|
||||
<description>Significantly improved rendering performance</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Increased initial memory allocation to 1GB for smoother performance</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Upgraded source code structure to modern standards and introduced Maven</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved robustness of series/parallel graph construction code used in circuit analysis</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Omit boards, wires, traces, terminals, etc from Spice netlist output</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Updated the windows installer (hopefully) to avoid false positive anti-virus detection</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Files containing Inductor Symbol fail to open</description>
|
||||
<description>Moving selected components with a mouse doesn't register file modification action and doesn't enable Undo action</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Rotating selected components sometimes wacks the alignment off the grid</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Ctrl+X (Command+X) shortcut for Cut action doesn't work because 'Project Explorer' steals the focus on X key press</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>6</major>
|
||||
<major>5</major>
|
||||
<minor>1</minor>
|
||||
<build>1</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-03-27 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Include windows ZIP package</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Windows version doesn't start in some cases</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>2</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-08-06 00:00:00.000 CET</releaseDate>
|
||||
<releaseDate>2025-04-12 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added two new view perspectives to Potentiometer component - Terminals Up and Terminals down</description>
|
||||
<description>Added 'AI Assistant' that can help with general electronics questions, questions about DIYLC usage and circuit-related questions</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Use either username of email to log into DIYLC cloud</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved comparison logic of the 'Compare With..' tool</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Align Potentiometer 1-2-3 markings with circuit analysis node labels; it used to be mixed up in some cases</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>6</major>
|
||||
<minor>3</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-08-22 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added support for stacked guitar pickups: 'Stacked - North' and 'Stacked - South' are two new options to pick in the Coil(s) property of Single Coil, P-90, P-Bass and Jazz Bass pickups</description>
|
||||
<description>'Virtual Multimeter' from 'Analyze' menu traces the circuit finding all possible paths of electricity between two points designated by the probe symbol</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Node Name Tooltips' feature that can be toggled in the Config menu; when enabled a tooltip is shown next to the cursor with names of component nodes under the cursor</description>
|
||||
<description>Added ability to display switch lug markings in order to illustrate how it works internally</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added a 'Save' button to all analysis screens which saves results of a circuit analysis to an HTML file</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added ability control if the board underside display should render as transparent or not</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added DIY Cloud password reset page</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Significantly improved AI Assistant's knowledge base on DIYLC usage by ingesting most of the material from the eBook</description>
|
||||
<description>Moved 'Analyze' functions from 'File' menu to their own menu for faster access</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved the accuracy of board underside rendering; some of the components were not rendered in the right place or at all</description>
|
||||
<description>Moved 'Highlight Connected Areas' feature from 'Config' menu to 'Analyze' menu</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Show a progress dialog while waiting for a long-running AI Analysis to complete</description>
|
||||
<description>Fully configurable colors for 'Mini Toggle Switch' components</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Renamed Mac OS build files to start with a 'mac' prefix instead of 'osx'</description>
|
||||
<description>Removed 'DP3T' options from 'Mini Toggle Switch' because that is covered by 'Slide Switch' component and does not belong here</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Include components in the underside display that have at least one control point laying in the board, as opposed to all</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Images can randomly disappear when zooming in and scrolling</description>
|
||||
<description>Applying a variant to a 'Hookup Wire' or 'Curved Trace' makes it lose its shape</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Copy operation doesn't work when certain component types are selected</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Board underside display does not work if there's a Label or PCB Text component on the board</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Using board underside display sometimes makes other components semi-transparent</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed Windows ZIP package issue with the bundled JRE</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>6</major>
|
||||
<major>5</major>
|
||||
<minor>3</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-04-21 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved AI Assistant quality of responses, especially when analyzing a circuit</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>When saving a project to the new file, retain all the AI Assistant chat history for the new project file</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Added ability to be logged into the same DIYLC Cloud account from several machines at the same time</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Confirmation dialog before deleting AI Assistant chat history</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Output current subscription statistics at the end of the chat for usage transparency</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved styling and usability of chatbot tool</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Language selection doesn't work on some OSs</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Connect to Patreon' option doesn't work if the user name contains a space or another non-alphanumerical character</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>4</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-08-22 00:00:00.000 CET</releaseDate>
|
||||
<releaseDate>2025-05-13 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Building blocks instantiate by default as a single component, inheriting control points and terminal nodes from all individual components but acting as a single component; still possible to instantiate individual components using 'Insert as Grouped Components' action from the context menu over a building block</description>
|
||||
<description>'AI Analyzer' feature added which uses AI to scan the circuit diagram and report issues and suggestions</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Significantly improve rendering performance of most components</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>'Open Jack 1/4"' and 'Potentiometer Panel' now tolerate connections anywhere on the lugs instead of dead center only</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Increased maximum number of switching combinations to 256 for circuit analysis</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Pilot Lamp Holder' component can sometimes hang the application</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed the issue with embedding image files into DIY projects</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed the issue with some components (e.g. DIP IC) jumping when showing underside of a board</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>5</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-05-26 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Compare With...' tool in the 'Analyze' menu that compares the content of two DIY files electronically and reports differences. Can be useful to compare two versions of the same circuit or validate a layout against the schematics file.</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Increased tolerance of sticky points on guitar pickup terminals in order to make it easier for leads to make proper contact and for the circuit analyzer to work</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved trace proximity calculation to avoid showing false positives</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved the styling of circuit analysis reports</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>X or Q keys sometimes do not register in secondary dialogs</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Auto-Edit Mode' doesn't do what it's supposed to</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>If the internet connection is present, but unstable, the application starts but nothing can be clicked until the connection restores</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>6</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-08-11 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Drill Hole' component that can be used for board mounting holes, chassis holes, faceplace holes, etc</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Simplify zoom in/out keyboard shortcuts to only plus/minus keys and zero numerical key for zoom reset to 100</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Bundle Java JRE with Linux AppImage to avoid having to install it</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Updated naming conventions Mac build packages to replace 'arm' with 'silicon' and 'x86' to 'intel' for clarity</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Allow Windows 64 bit installer to run on ARM-based Windows machine (through emulation)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>More intuitive user account creation dialog for DIYLC Cloud - showing exact requirements for password and marking optional entries</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved project search algorithm in DIYLC cloud</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>When a switch position is selected (i.e. set to a value other than None), DIYLC will treat the terminals that are internally connected in that switching logic as connected in analysis tools</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Increase maximum size of the backup folder from 64MB to 1GB for deeper history</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Alignment issues of some visual elements in the resulting Gerber files, e.g. DIL IC pin designators</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Connect to Patreon' option says that it connected account with username 'a b c' but doesn't do anything</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>7</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-12-21 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added '6P5T (5-Position 6 Pole AxLabs)' lever switch type (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added ability to set node name (or names) for some connectivity components (e.g. Solder Pad, Eyelet, PCB Terminal Block, etc); when combined into building blocks, these names will become node names of the composite component stamped from the building block</description>
|
||||
<description>Added '4P3T (3-Position 4 Pole AxLabs)' lever switch type (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'DP3T (Import 5-Position 2502N)' lever switch type (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Include building blocks in the Recently Used category</description>
|
||||
<description>Corrected 'S1 Switch' up/down position designators (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>When saving building blocks, present a drop down list with most recently used building blocks for quick selection</description>
|
||||
<description>Corrected 'Mini Toggle Switch' position names for center-OFF variants to be in the correct order (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Prompt to confirm the overwrite when saving over the existing building blocks</description>
|
||||
<description>'Drill Hole' changes color to red when selected</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>8</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-12-21 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>When transistor pinout is selected for TO-1, TO-92, TO-126, TO-220 transistor, the corresponding electrode name will be used as a node name in programmatical and AI analysis</description>
|
||||
<description>Improved sensitivity of 'Multimeter Probe' that required pixel-level precision to detect connectivity; improved rendering of the probe in outline mode</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Diode components now label their terminal nodes as 'A' (anode) and 'K' (cathode) instead of '1' and '2'</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Capacitor components now label their terminal nodes as '+' and '-' instead of '1' and '2' when 'Polarized' property is ticked</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Percentage values such as transparency Alpha, image Scale, etc, can have decimal values and not just integers</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Made announcement bubbles and dialogs that contain links clickable</description>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed underside rendering and mirroring position issues that affected only SPDT 'Mini Toggle Switch' types</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
|
||||
@@ -4773,557 +4773,5 @@
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>4</major>
|
||||
<minor>41</minor>
|
||||
<build>1</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-03-08 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Do not mirror bottom layers for Gerber export as fabrication service providers expect a top view for everything</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Selecting components by drawing a rectangle around them works glitchy</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>0</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-03-09 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Switched to AppImage distribution for Linux system, abandoning Flatpak as a means of distribution. DIYLC AppImage will be available alongside with other executables on the official DIYLC GitHub page.</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Upgraded Windows installer version and Windows EXE launcher version</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed alignment issues of round elements (e.g. solder pads and holes) in exported Gerber files</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed the issue with opening DIY files on Mac OS</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>1</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-03-24 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added ability to render the underside of boards along with the top side for easier validation, building and debugging</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Configurable 'High DPI Rendering' feature which makes the diagram smoother on high-resolution displays but can affect performance</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Significantly improved rendering performance</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Increased initial memory allocation to 1GB for smoother performance</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Upgraded source code structure to modern standards and introduced Maven</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved robustness of series/parallel graph construction code used in circuit analysis</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Omit boards, wires, traces, terminals, etc from Spice netlist output</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Updated the windows installer (hopefully) to avoid false positive anti-virus detection</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Moving selected components with a mouse doesn't register file modification action and doesn't enable Undo action</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Rotating selected components sometimes wacks the alignment off the grid</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Ctrl+X (Command+X) shortcut for Cut action doesn't work because 'Project Explorer' steals the focus on X key press</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>1</minor>
|
||||
<build>1</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-03-27 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Include windows ZIP package</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Windows version doesn't start in some cases</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>2</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-04-12 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'AI Assistant' that can help with general electronics questions, questions about DIYLC usage and circuit-related questions</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>'Virtual Multimeter' from 'Analyze' menu traces the circuit finding all possible paths of electricity between two points designated by the probe symbol</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added ability to display switch lug markings in order to illustrate how it works internally</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added a 'Save' button to all analysis screens which saves results of a circuit analysis to an HTML file</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added ability control if the board underside display should render as transparent or not</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added DIY Cloud password reset page</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Moved 'Analyze' functions from 'File' menu to their own menu for faster access</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Moved 'Highlight Connected Areas' feature from 'Config' menu to 'Analyze' menu</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Fully configurable colors for 'Mini Toggle Switch' components</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Removed 'DP3T' options from 'Mini Toggle Switch' because that is covered by 'Slide Switch' component and does not belong here</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Include components in the underside display that have at least one control point laying in the board, as opposed to all</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Applying a variant to a 'Hookup Wire' or 'Curved Trace' makes it lose its shape</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Copy operation doesn't work when certain component types are selected</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Board underside display does not work if there's a Label or PCB Text component on the board</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Using board underside display sometimes makes other components semi-transparent</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed Windows ZIP package issue with the bundled JRE</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>3</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-04-21 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved AI Assistant quality of responses, especially when analyzing a circuit</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>When saving a project to the new file, retain all the AI Assistant chat history for the new project file</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Added ability to be logged into the same DIYLC Cloud account from several machines at the same time</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Confirmation dialog before deleting AI Assistant chat history</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Output current subscription statistics at the end of the chat for usage transparency</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved styling and usability of chatbot tool</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Language selection doesn't work on some OSs</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Connect to Patreon' option doesn't work if the user name contains a space or another non-alphanumerical character</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>4</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-05-13 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>'AI Analyzer' feature added which uses AI to scan the circuit diagram and report issues and suggestions</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Significantly improve rendering performance of most components</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>'Open Jack 1/4"' and 'Potentiometer Panel' now tolerate connections anywhere on the lugs instead of dead center only</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Increased maximum number of switching combinations to 256 for circuit analysis</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Pilot Lamp Holder' component can sometimes hang the application</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed the issue with embedding image files into DIY projects</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed the issue with some components (e.g. DIP IC) jumping when showing underside of a board</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>5</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-05-26 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Compare With...' tool in the 'Analyze' menu that compares the content of two DIY files electronically and reports differences. Can be useful to compare two versions of the same circuit or validate a layout against the schematics file.</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Increased tolerance of sticky points on guitar pickup terminals in order to make it easier for leads to make proper contact and for the circuit analyzer to work</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved trace proximity calculation to avoid showing false positives</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved the styling of circuit analysis reports</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>X or Q keys sometimes do not register in secondary dialogs</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Auto-Edit Mode' doesn't do what it's supposed to</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>If the internet connection is present, but unstable, the application starts but nothing can be clicked until the connection restores</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>6</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-08-11 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Drill Hole' component that can be used for board mounting holes, chassis holes, faceplace holes, etc</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Simplify zoom in/out keyboard shortcuts to only plus/minus keys and zero numerical key for zoom reset to 100</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Bundle Java JRE with Linux AppImage to avoid having to install it</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Updated naming conventions Mac build packages to replace 'arm' with 'silicon' and 'x86' to 'intel' for clarity</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Allow Windows 64 bit installer to run on ARM-based Windows machine (through emulation)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>More intuitive user account creation dialog for DIYLC Cloud - showing exact requirements for password and marking optional entries</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved project search algorithm in DIYLC cloud</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>When a switch position is selected (i.e. set to a value other than None), DIYLC will treat the terminals that are internally connected in that switching logic as connected in analysis tools</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Increase maximum size of the backup folder from 64MB to 1GB for deeper history</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Alignment issues of some visual elements in the resulting Gerber files, e.g. DIL IC pin designators</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Connect to Patreon' option says that it connected account with username 'a b c' but doesn't do anything</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>7</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-12-21 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added '6P5T (5-Position 6 Pole AxLabs)' lever switch type (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added '4P3T (3-Position 4 Pole AxLabs)' lever switch type (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'DP3T (Import 5-Position 2502N)' lever switch type (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Corrected 'S1 Switch' up/down position designators (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Corrected 'Mini Toggle Switch' position names for center-OFF variants to be in the correct order (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>'Drill Hole' changes color to red when selected</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>8</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2025-12-30 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added Silkscreen export to PDF/PNG and print capabilities</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Multiwatt IC' package with 11 and 15 pin varieties</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added new property in 'LP Switch' that allows having the middle terminals connected (as they were) or disconnected to allow more flexibility</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Ending Style' property to 'Copper Trace' and 'Curved Trace' to allow choosing round or flat style</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added Chinese simplified (thank you chenjingyuanku) and Hindi UI translation and updated all other languages with new translations</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added configuration for text scale factor in rare cases when system scale factor is not applied correctly; requires adding a configuration property to config.xml with key 'fontScaleFactor' and a desired float value</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved behavior of mouse cursor during drag operations; this should also fix behavior on some linux machines that show a "forbidden" cursor while dragging</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved sensitivity of 'Multimeter Probe' that required pixel-level precision to detect connectivity; improved rendering of the probe in outline mode</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improve contrast of tooltips on some Linux machines that show white text against yellow balloon</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Honor label color settings for 'Tape Measure' component</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Reorganized export and print related items in the File menu to reduce clutter</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed underside rendering and mirroring position issues that affected only SPDT 'Mini Toggle Switch' types</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Application freezes when using underside rendering or mirroring on 'Pin Header' when sized at 1x1</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>'Rotary Switch (Open)' cannot be selected by clicking on the wafer for 4-pole variations</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>5</major>
|
||||
<minor>9</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2026-01-10 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added ability to name groups of components</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Show groups of components as single items in the Project Explorer list</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added balloon tooltip next to cursor showing component width, height and length (where available) while resizing; can be disabled from Config menu</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added 'Freeway 3x3-05 (Ultra) Switch' (thank you mm-rnd)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Configurable 'Tactile Micro Switch' dimensions and added a few most commonly used variants</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Exposed the most common pin pairing modes and added switching logic for 'Tactile Micro Switch' to allow using it for analysis</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>'Potentiometer Panel' can now render numerical lug markers for easier identification</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>'Auto-Wrap Label' retains line breaks from the input text</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>'Cliff 1/8" Jack', 'Open 1/8" Jack' and 'Open 1/4" Jack' can be rotated</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Fixed the offset of terminals on a DP4T Tele type of 'Lever Switch' to be aligned with the physical switch (attention - this will break existing diagrams and will require adjusting leads to match the new terminal positions)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Make the label of schematic symbols (e.g. 'Resistor Symbol') clickable as well</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Ability to resize 'Transformer Core' schematic symbol after it's already placed</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Clicking on 'Tactile Micro Switch' body doesn't register</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>New lines at the end of the 'Label' text get erroneously rendered as br HTML tags</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
</a>
|
||||
</java.util.Arrays_-ArrayList>
|
||||
|
||||
-224
@@ -1,224 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.composite;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.diylc.common.Percentage;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.netlist.Node;
|
||||
import org.diylc.serialization.ProjectFileManager;
|
||||
import org.diylc.testcomponents.TwoPointTestComponent;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Exercises the delegation, rigidity, cloning and equality behavior described in
|
||||
* {@code docs/plans/composite-building-blocks.md}.
|
||||
*/
|
||||
public class CompositeComponentTest {
|
||||
|
||||
private CompositeComponent twoChildComposite() {
|
||||
CompositeComponent composite = new CompositeComponent();
|
||||
composite.setName("BLK1");
|
||||
composite.initBlockName("Test Block");
|
||||
composite.getChildComponents().add(new TwoPointTestComponent("R1",
|
||||
new Point2D.Double(0, 0), new Point2D.Double(10, 0)));
|
||||
composite.getChildComponents().add(new TwoPointTestComponent("R2",
|
||||
new Point2D.Double(20, 0), new Point2D.Double(30, 0)));
|
||||
return composite;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void controlPointCountIsSumOverChildren() {
|
||||
CompositeComponent composite = twoChildComposite();
|
||||
assertEquals(4, composite.getControlPointCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void controlPointsMapToTheRightChildAndLocalIndex() {
|
||||
CompositeComponent composite = twoChildComposite();
|
||||
|
||||
assertEquals(new Point2D.Double(0, 0), composite.getControlPoint(0));
|
||||
assertEquals(new Point2D.Double(10, 0), composite.getControlPoint(1));
|
||||
assertEquals(new Point2D.Double(20, 0), composite.getControlPoint(2));
|
||||
assertEquals(new Point2D.Double(30, 0), composite.getControlPoint(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setControlPointDelegatesToTheOwningChild() {
|
||||
CompositeComponent composite = twoChildComposite();
|
||||
|
||||
composite.setControlPoint(new Point2D.Double(99, 99), 2);
|
||||
|
||||
assertEquals(new Point2D.Double(99, 99), composite.getControlPoint(2));
|
||||
// the sibling child's points must be untouched
|
||||
assertEquals(new Point2D.Double(30, 0), composite.getControlPoint(3));
|
||||
TwoPointTestComponent r2 = (TwoPointTestComponent) composite.getChildComponents().get(1);
|
||||
assertEquals(new Point2D.Double(99, 99), r2.getControlPoint(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stickinessIsDelegatedPerChildPoint() {
|
||||
CompositeComponent composite = twoChildComposite();
|
||||
((TwoPointTestComponent) composite.getChildComponents().get(0)).setSticky(1, false);
|
||||
|
||||
assertTrue(composite.isControlPointSticky(0));
|
||||
assertFalse(composite.isControlPointSticky(1));
|
||||
assertTrue(composite.isControlPointSticky(2));
|
||||
assertTrue(composite.isControlPointSticky(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAlwaysRigid() {
|
||||
CompositeComponent composite = twoChildComposite();
|
||||
for (int i = 0; i < composite.getControlPointCount(); i++)
|
||||
assertFalse("point " + i + " should not move freely", composite.canPointMoveFreely(i));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nodeNamingProducesHierarchicalNetlistLabels() {
|
||||
// Design decision D3: Node.toString() should read "<composite>.<child>.<local point name>"
|
||||
CompositeComponent composite = twoChildComposite();
|
||||
|
||||
Node r1FirstPoint = new Node(composite, 0);
|
||||
Node r2FirstPoint = new Node(composite, 2);
|
||||
Node r2SecondPoint = new Node(composite, 3);
|
||||
|
||||
assertEquals("BLK1.1", r1FirstPoint.toString());
|
||||
assertEquals("BLK1.1", r2FirstPoint.toString());
|
||||
// local point index must reset per child, not keep growing with the flat composite index
|
||||
assertEquals("BLK1.2", r2SecondPoint.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cloneDeepCopiesChildrenSoInstancesAreIndependent() throws Exception {
|
||||
CompositeComponent original = twoChildComposite();
|
||||
|
||||
IDIYComponent<?> clone = original.clone();
|
||||
|
||||
((CompositeComponent) clone).setControlPoint(new Point2D.Double(-1, -1), 0);
|
||||
|
||||
assertEquals(new Point2D.Double(0, 0), original.getControlPoint(0));
|
||||
assertEquals(new Point2D.Double(-1, -1), clone.getControlPoint(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cloneKeepsBothItsOwnAndChildrenIds() throws Exception {
|
||||
// Matches AbstractComponent.clone()'s contract of preserving identity by default - a caller
|
||||
// that needs a genuinely new component (e.g. BuildingBlockManager placing a fresh instance)
|
||||
// reassigns ids itself, exactly as it does for any other component's clone().
|
||||
CompositeComponent original = twoChildComposite();
|
||||
UUID originalChildId = original.getChildComponents().get(0).getId();
|
||||
|
||||
CompositeComponent clone = (CompositeComponent) original.clone();
|
||||
|
||||
assertEquals(original.getId(), clone.getId());
|
||||
assertEquals(originalChildId, clone.getChildComponents().get(0).getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsToComparesStructureNotObjectIdentity() throws Exception {
|
||||
CompositeComponent original = twoChildComposite();
|
||||
CompositeComponent clone = (CompositeComponent) original.clone();
|
||||
|
||||
// structurally identical, distinct child objects - must still compare equal
|
||||
assertTrue(original.equalsTo(clone));
|
||||
|
||||
clone.setControlPoint(new Point2D.Double(-1, -1), 0);
|
||||
assertFalse(original.equalsTo(clone));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsToRejectsDifferentBlockName() {
|
||||
CompositeComponent a = twoChildComposite();
|
||||
CompositeComponent b = twoChildComposite();
|
||||
b.initBlockName("Different Block");
|
||||
|
||||
assertFalse(a.equalsTo(b));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultsToFullyOpaque() {
|
||||
assertEquals(new Percentage(100), twoChildComposite().getAlpha());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cloneCopiesAlpha() throws Exception {
|
||||
CompositeComponent original = twoChildComposite();
|
||||
original.setAlpha(new Percentage(40));
|
||||
|
||||
CompositeComponent clone = (CompositeComponent) original.clone();
|
||||
|
||||
assertEquals(new Percentage(40), clone.getAlpha());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsToRejectsDifferentAlpha() throws Exception {
|
||||
CompositeComponent original = twoChildComposite();
|
||||
CompositeComponent clone = (CompositeComponent) original.clone();
|
||||
assertTrue(original.equalsTo(clone));
|
||||
|
||||
clone.setAlpha(new Percentage(50));
|
||||
assertFalse(original.equalsTo(clone));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void survivesAnXStreamRoundTripAndRebuildsItsIndexLazily() {
|
||||
CompositeComponent original = twoChildComposite();
|
||||
|
||||
String xml = ProjectFileManager.xStreamSerializer.toXML(original);
|
||||
CompositeComponent reloaded = (CompositeComponent) ProjectFileManager.xStreamSerializer.fromXML(xml);
|
||||
|
||||
// the transient child-index arrays are never serialized - this call exercises the lazy
|
||||
// rebuild in buildIndexIfNeeded() on an instance XStream constructed without going through
|
||||
// the no-arg constructor
|
||||
assertEquals(original.getControlPointCount(), reloaded.getControlPointCount());
|
||||
assertEquals(original.getName(), reloaded.getName());
|
||||
assertEquals(original.getBlockName(), reloaded.getBlockName());
|
||||
for (int i = 0; i < original.getControlPointCount(); i++)
|
||||
assertEquals(original.getControlPoint(i), reloaded.getControlPoint(i));
|
||||
assertEquals("BLK1.2", new Node(reloaded, 3).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawIconDoesNotTouchChildren() {
|
||||
// ComponentProcessor draws the palette icon on a default-constructed, childless instance
|
||||
CompositeComponent blank = new CompositeComponent();
|
||||
BufferedImage image = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = image.createGraphics();
|
||||
|
||||
blank.drawIcon(g2d, 32, 32);
|
||||
|
||||
g2d.dispose();
|
||||
// no exception means components list (empty) was never dereferenced as if populated
|
||||
assertNotNull(blank.getChildComponents());
|
||||
assertTrue(blank.getChildComponents().isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -1,242 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.core.measures;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class SizeTest {
|
||||
|
||||
private static final double DELTA = 1e-9;
|
||||
|
||||
// --- convertToUnits: same unit ---
|
||||
|
||||
@Test
|
||||
public void convertToUnits_sameUnit_returnsNewSizeWithValueRoundedTo4Decimals() {
|
||||
Size size = new Size(1.23456789, SizeUnit.mm);
|
||||
Size result = size.convertToUnits(SizeUnit.mm);
|
||||
assertNotSame(size, result);
|
||||
assertEquals(SizeUnit.mm, result.getUnit());
|
||||
assertEquals(1.2346, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToUnits_sameUnit_roundsTo4Decimals() {
|
||||
assertEquals(2.3457, new Size(2.3456789, SizeUnit.cm).convertToUnits(SizeUnit.cm).getValue(), DELTA);
|
||||
assertEquals(0.5, new Size(0.5, SizeUnit.in).convertToUnits(SizeUnit.in).getValue(), DELTA);
|
||||
}
|
||||
|
||||
// --- convertToUnits: metric ↔ metric ---
|
||||
|
||||
@Test
|
||||
public void convertToUnits_mmToCm() {
|
||||
Size size = new Size(10.0, SizeUnit.mm);
|
||||
Size result = size.convertToUnits(SizeUnit.cm);
|
||||
assertEquals(SizeUnit.cm, result.getUnit());
|
||||
assertEquals(1.0, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToUnits_cmToMm() {
|
||||
Size size = new Size(2.5, SizeUnit.cm);
|
||||
Size result = size.convertToUnits(SizeUnit.mm);
|
||||
assertEquals(SizeUnit.mm, result.getUnit());
|
||||
assertEquals(25.0, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToUnits_mmToM() {
|
||||
Size size = new Size(1500.0, SizeUnit.mm);
|
||||
Size result = size.convertToUnits(SizeUnit.m);
|
||||
assertEquals(SizeUnit.m, result.getUnit());
|
||||
assertEquals(1.5, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToUnits_mToMm() {
|
||||
Size size = new Size(0.5, SizeUnit.m);
|
||||
Size result = size.convertToUnits(SizeUnit.mm);
|
||||
assertEquals(SizeUnit.mm, result.getUnit());
|
||||
assertEquals(500.0, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
// --- convertToUnits: imperial ↔ imperial ---
|
||||
|
||||
@Test
|
||||
public void convertToUnits_inToFt() {
|
||||
Size size = new Size(24.0, SizeUnit.in);
|
||||
Size result = size.convertToUnits(SizeUnit.ft);
|
||||
assertEquals(SizeUnit.ft, result.getUnit());
|
||||
assertEquals(2.0, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToUnits_ftToIn() {
|
||||
Size size = new Size(1.0, SizeUnit.ft);
|
||||
Size result = size.convertToUnits(SizeUnit.in);
|
||||
assertEquals(SizeUnit.in, result.getUnit());
|
||||
assertEquals(12.0, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
// --- convertToUnits: metric ↔ imperial ---
|
||||
|
||||
@Test
|
||||
public void convertToUnits_mmToIn() {
|
||||
Size size = new Size(25.4, SizeUnit.mm);
|
||||
Size result = size.convertToUnits(SizeUnit.in);
|
||||
assertEquals(SizeUnit.in, result.getUnit());
|
||||
assertEquals(1.0, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToUnits_inToMm() {
|
||||
Size size = new Size(1.0, SizeUnit.in);
|
||||
Size result = size.convertToUnits(SizeUnit.mm);
|
||||
assertEquals(SizeUnit.mm, result.getUnit());
|
||||
assertEquals(25.4, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToUnits_cmToIn() {
|
||||
Size size = new Size(2.54, SizeUnit.cm);
|
||||
Size result = size.convertToUnits(SizeUnit.in);
|
||||
assertEquals(SizeUnit.in, result.getUnit());
|
||||
assertEquals(1.0, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
// --- convertToUnits: rounding to 4 decimal places ---
|
||||
|
||||
@Test
|
||||
public void convertToUnits_resultIsRoundedTo4Decimals() {
|
||||
Size size = new Size(1.0, SizeUnit.mm);
|
||||
Size result = size.convertToUnits(SizeUnit.in);
|
||||
// 1 mm = 1/25.4 in ≈ 0.03937007874015748...
|
||||
assertEquals(0.0394, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToUnits_roundingDown() {
|
||||
Size size = new Size(1.23441, SizeUnit.mm);
|
||||
Size result = size.convertToUnits(SizeUnit.mm);
|
||||
assertEquals(1.2344, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToUnits_roundingUp() {
|
||||
Size size = new Size(1.23446, SizeUnit.mm);
|
||||
Size result = size.convertToUnits(SizeUnit.mm);
|
||||
assertEquals(1.2345, result.getValue(), DELTA);
|
||||
}
|
||||
|
||||
// --- parseSize ---
|
||||
|
||||
@Test
|
||||
public void parseSize_mm() {
|
||||
Size size = Size.parseSize("10.5mm");
|
||||
assertEquals(10.5, size.getValue(), DELTA);
|
||||
assertEquals(SizeUnit.mm, size.getUnit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseSize_cm() {
|
||||
Size size = Size.parseSize("2.54cm");
|
||||
assertEquals(2.54, size.getValue(), DELTA);
|
||||
assertEquals(SizeUnit.cm, size.getUnit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseSize_in() {
|
||||
Size size = Size.parseSize("1in");
|
||||
assertEquals(1.0, size.getValue(), DELTA);
|
||||
assertEquals(SizeUnit.in, size.getUnit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseSize_caseInsensitive() {
|
||||
Size size = Size.parseSize("5 MM");
|
||||
assertEquals(5.0, size.getValue(), DELTA);
|
||||
assertEquals(SizeUnit.mm, size.getUnit());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void parseSize_unknownUnit_throws() {
|
||||
Size.parseSize("10 xyz");
|
||||
}
|
||||
|
||||
// --- fromPixels ---
|
||||
|
||||
@Test
|
||||
public void fromPixels_roundTripWithConvertToPixels() {
|
||||
Size original = new Size(1.0, SizeUnit.in);
|
||||
double pixels = original.convertToPixels();
|
||||
Size fromPixels = Size.fromPixels(pixels, SizeUnit.in);
|
||||
assertEquals(original.getValue(), fromPixels.getValue(), 0.01);
|
||||
assertEquals(original.getUnit(), fromPixels.getUnit());
|
||||
}
|
||||
|
||||
// --- scale ---
|
||||
|
||||
@Test
|
||||
public void scale() {
|
||||
Size size = new Size(10.0, SizeUnit.mm);
|
||||
Size scaled = size.scale(2.0);
|
||||
assertEquals(20.0, scaled.getValue(), DELTA);
|
||||
assertEquals(SizeUnit.mm, scaled.getUnit());
|
||||
}
|
||||
|
||||
// --- compareTo ---
|
||||
|
||||
@Test
|
||||
public void compareTo_samePhysicalSize_returnsZero() {
|
||||
Size a = new Size(25.4, SizeUnit.mm);
|
||||
Size b = new Size(1.0, SizeUnit.in);
|
||||
assertEquals(0, a.compareTo(b));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compareTo_smaller_returnsNegative() {
|
||||
Size a = new Size(1.0, SizeUnit.mm);
|
||||
Size b = new Size(1.0, SizeUnit.cm);
|
||||
assertTrue(a.compareTo(b) < 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compareTo_larger_returnsPositive() {
|
||||
Size a = new Size(10.0, SizeUnit.mm);
|
||||
Size b = new Size(1.0, SizeUnit.mm);
|
||||
assertTrue(a.compareTo(b) > 0);
|
||||
}
|
||||
|
||||
// --- clone ---
|
||||
|
||||
@Test
|
||||
public void clone_returnsEqualSize() throws CloneNotSupportedException {
|
||||
Size size = new Size(3.14, SizeUnit.cm);
|
||||
Size cloned = size.clone();
|
||||
assertNotSame(size, cloned);
|
||||
assertEquals(size.getValue(), cloned.getValue(), DELTA);
|
||||
assertEquals(size.getUnit(), cloned.getUnit());
|
||||
}
|
||||
}
|
||||
+83
-90
@@ -48,34 +48,33 @@ public class CompareServiceTest {
|
||||
|
||||
@Test
|
||||
public void testCompare_MissingConnectionsInSecondNetlist() {
|
||||
Map<String, IDIYComponent<?>> componentMap1 = new HashMap<>();
|
||||
Netlist netlist1 = createNetlist(componentMap1, "Component1", "Node1", "Component2", "Node2", "Component3", "Node3");
|
||||
Map<String, IDIYComponent<?>> componentMap2 = new HashMap<>();
|
||||
Netlist netlist2 = createNetlist(componentMap2, "Component1", "Node1"); // Missing components 2 & 3
|
||||
Map<String, IDIYComponent<?>> componentMap = new HashMap<>();
|
||||
// Group will have 3 nodes
|
||||
Netlist netlist1 = createNetlist(componentMap, "Component1", "Node1", "Component2", "Node2", "Component3", "Node3");
|
||||
Netlist netlist2 = createNetlist(componentMap, "Component1", "Node1"); // Missing group with 2 nodes
|
||||
|
||||
CompareResults results = compareService.compare(netlist1, netlist2);
|
||||
|
||||
assertTrue(!results.matches());
|
||||
// 2 components missing = 2 component diffs
|
||||
assertEquals(2, results.componentDiffs().size());
|
||||
// Connections involving missing components are filtered out, so 0 connection diffs
|
||||
assertEquals(0, results.connectionDiffs().size());
|
||||
// 3 nodes = 3 connections (1-2, 1-3, 2-3)
|
||||
assertEquals(3, results.connectionDiffs().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompare_MissingConnectionsInFirstNetlist() {
|
||||
Map<String, IDIYComponent<?>> componentMap1 = new HashMap<>();
|
||||
Netlist netlist1 = createNetlist(componentMap1, "Component1", "Node1");
|
||||
Map<String, IDIYComponent<?>> componentMap2 = new HashMap<>();
|
||||
Netlist netlist2 = createNetlist(componentMap2, "Component1", "Node1", "Component2", "Node2", "Component3", "Node3");
|
||||
Map<String, IDIYComponent<?>> componentMap = new HashMap<>();
|
||||
// Group will have 3 nodes
|
||||
Netlist netlist1 = createNetlist(componentMap, "Component1", "Node1");
|
||||
Netlist netlist2 = createNetlist(componentMap, "Component1", "Node1", "Component2", "Node2", "Component3", "Node3");
|
||||
|
||||
CompareResults results = compareService.compare(netlist1, netlist2);
|
||||
|
||||
assertTrue(!results.matches());
|
||||
// 2 components missing = 2 component diffs
|
||||
assertEquals(2, results.componentDiffs().size());
|
||||
// Connections involving missing components are filtered out, so 0 connection diffs
|
||||
assertEquals(0, results.connectionDiffs().size());
|
||||
assertEquals(3, results.connectionDiffs().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,8 +89,8 @@ public class CompareServiceTest {
|
||||
assertTrue(!results.matches());
|
||||
// 4 components missing (2 in each netlist) = 4 component diffs
|
||||
assertEquals(4, results.componentDiffs().size());
|
||||
// Connections involving missing components are filtered out, so 0 connection diffs
|
||||
assertEquals(0, results.connectionDiffs().size());
|
||||
// 2 connections in each netlist = 2 connection diffs
|
||||
assertEquals(2, results.connectionDiffs().size());
|
||||
|
||||
// Verify differences from first netlist
|
||||
List<ComponentDiff> firstNetlistComponentDiffs = results.componentDiffs().stream()
|
||||
@@ -110,15 +109,13 @@ public class CompareServiceTest {
|
||||
public void testCompare_MultipleGroups_Identical() {
|
||||
Map<String, IDIYComponent<?>> componentMap = new HashMap<>();
|
||||
|
||||
// Create groups first so componentMap is populated
|
||||
Group g1a = createGroup(componentMap, "Component1", "Node1", "Component2", "Node2");
|
||||
Group g1b = createGroup(componentMap, "Component3", "Node3", "Component4", "Node4");
|
||||
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
netlist1.add(g1a);
|
||||
netlist1.add(g1b);
|
||||
// Create first netlist with two groups
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>());
|
||||
netlist1.add(createGroup(componentMap, "Component1", "Node1", "Component2", "Node2"));
|
||||
netlist1.add(createGroup(componentMap, "Component3", "Node3", "Component4", "Node4"));
|
||||
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
// Create second netlist with same groups
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>());
|
||||
netlist2.add(createGroup(componentMap, "Component1", "Node1", "Component2", "Node2"));
|
||||
netlist2.add(createGroup(componentMap, "Component3", "Node3", "Component4", "Node4"));
|
||||
|
||||
@@ -133,16 +130,13 @@ public class CompareServiceTest {
|
||||
public void testCompare_MultipleGroups_DifferentOrder() {
|
||||
Map<String, IDIYComponent<?>> componentMap = new HashMap<>();
|
||||
|
||||
// Create groups first so componentMap is populated
|
||||
Group g1a = createGroup(componentMap, "Component1", "Node1", "Component2", "Node2");
|
||||
Group g1b = createGroup(componentMap, "Component3", "Node3", "Component4", "Node4");
|
||||
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
netlist1.add(g1a);
|
||||
netlist1.add(g1b);
|
||||
// Create first netlist with two groups
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>());
|
||||
netlist1.add(createGroup(componentMap, "Component1", "Node1", "Component2", "Node2"));
|
||||
netlist1.add(createGroup(componentMap, "Component3", "Node3", "Component4", "Node4"));
|
||||
|
||||
// Same groups but in different order
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
// Create second netlist with same groups but in different order
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>());
|
||||
netlist2.add(createGroup(componentMap, "Component3", "Node3", "Component4", "Node4"));
|
||||
netlist2.add(createGroup(componentMap, "Component1", "Node1", "Component2", "Node2"));
|
||||
|
||||
@@ -155,45 +149,33 @@ public class CompareServiceTest {
|
||||
|
||||
@Test
|
||||
public void testCompare_MultipleGroups_ExtraGroup() {
|
||||
Map<String, IDIYComponent<?>> componentMap1 = new HashMap<>();
|
||||
// Create shared groups first
|
||||
Group shared1 = createGroup(componentMap1, "Component1", "Node1", "Component2", "Node2");
|
||||
Group shared2 = createGroup(componentMap1, "Component3", "Node3", "Component4", "Node4");
|
||||
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>(componentMap1.values()));
|
||||
netlist1.add(shared1);
|
||||
netlist1.add(shared2);
|
||||
|
||||
Map<String, IDIYComponent<?>> componentMap2 = new HashMap<>();
|
||||
Group shared2_1 = createGroup(componentMap2, "Component1", "Node1", "Component2", "Node2");
|
||||
Group shared2_2 = createGroup(componentMap2, "Component3", "Node3", "Component4", "Node4");
|
||||
Group extra = createGroup(componentMap2, "Component5", "Node5", "Component6", "Node6");
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>(componentMap2.values()));
|
||||
netlist2.add(shared2_1);
|
||||
netlist2.add(shared2_2);
|
||||
netlist2.add(extra);
|
||||
Map<String, IDIYComponent<?>> componentMap = new HashMap<>();
|
||||
// Each group has 2 nodes
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>());
|
||||
netlist1.add(createGroup(componentMap, "Component1", "Node1", "Component2", "Node2"));
|
||||
netlist1.add(createGroup(componentMap, "Component3", "Node3", "Component4", "Node4"));
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>());
|
||||
netlist2.add(createGroup(componentMap, "Component1", "Node1", "Component2", "Node2"));
|
||||
netlist2.add(createGroup(componentMap, "Component3", "Node3", "Component4", "Node4"));
|
||||
netlist2.add(createGroup(componentMap, "Component5", "Node5", "Component6", "Node6"));
|
||||
|
||||
CompareResults results = compareService.compare(netlist1, netlist2);
|
||||
|
||||
assertTrue(!results.matches());
|
||||
// 2 components in extra group = 2 component diffs
|
||||
assertEquals(2, results.componentDiffs().size());
|
||||
// Connections to/from missing Component5/6 are filtered out, so 0 connection diffs
|
||||
assertEquals(0, results.connectionDiffs().size());
|
||||
// 1 connection in extra group = 1 connection diff
|
||||
assertEquals(1, results.connectionDiffs().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompare_MultipleGroups_DifferentConnections() {
|
||||
Map<String, IDIYComponent<?>> componentMap = new HashMap<>();
|
||||
// Create groups first so componentMap is populated
|
||||
Group g1a = createGroup(componentMap, "Component1", "Node1", "Component2", "Node2");
|
||||
Group g1b = createGroup(componentMap, "Component3", "Node3", "Component4", "Node4");
|
||||
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
netlist1.add(g1a);
|
||||
netlist1.add(g1b);
|
||||
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
// Each group has 2 nodes
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>());
|
||||
netlist1.add(createGroup(componentMap, "Component1", "Node1", "Component2", "Node2"));
|
||||
netlist1.add(createGroup(componentMap, "Component3", "Node3", "Component4", "Node4"));
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>());
|
||||
netlist2.add(createGroup(componentMap, "Component1", "Node1", "Component3", "Node3"));
|
||||
netlist2.add(createGroup(componentMap, "Component2", "Node2", "Component4", "Node4"));
|
||||
|
||||
@@ -209,19 +191,20 @@ public class CompareServiceTest {
|
||||
public void testCompare_NonPolarizedComponent_SwappedNodes() {
|
||||
Map<String, IDIYComponent<?>> componentMap = new HashMap<>();
|
||||
|
||||
// Create groups first so componentMap is populated
|
||||
Group g1a = createGroup(componentMap, "Resistor1", "Node1", "Component2", "Node2");
|
||||
Group g1b = createGroup(componentMap, "Resistor1", "Node2", "Component3", "Node3");
|
||||
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
netlist1.add(g1a);
|
||||
netlist1.add(g1b);
|
||||
// Create first netlist with non-polarized component in two groups
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>());
|
||||
netlist1.add(createGroup(componentMap, "Resistor1", "Node1", "Component2", "Node2"));
|
||||
netlist1.add(createGroup(componentMap, "Resistor1", "Node2", "Component3", "Node3"));
|
||||
|
||||
// Same connections but different node order
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
// Create second netlist with same connections but different node order
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>());
|
||||
netlist2.add(createGroup(componentMap, "Resistor1", "Node2", "Component2", "Node2"));
|
||||
netlist2.add(createGroup(componentMap, "Resistor1", "Node1", "Component3", "Node3"));
|
||||
|
||||
// Make Resistor1 non-polarized
|
||||
IDIYComponent<?> resistor = componentMap.get("Resistor1");
|
||||
when(resistor.isPolarized()).thenReturn(false);
|
||||
|
||||
CompareResults results = compareService.compare(netlist1, netlist2);
|
||||
|
||||
assertTrue(results.matches());
|
||||
@@ -231,6 +214,9 @@ public class CompareServiceTest {
|
||||
|
||||
@Test
|
||||
public void testCompare_PolarizedComponent_SwappedNodes() {
|
||||
// Create first netlist with polarized component in two groups
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>());
|
||||
|
||||
// Create diode for netlist1
|
||||
IDIYComponent<?> diode1 = mock(IDIYComponent.class);
|
||||
when(diode1.getName()).thenReturn("Diode1");
|
||||
@@ -239,6 +225,7 @@ public class CompareServiceTest {
|
||||
when(diode1.getControlPoint(1)).thenReturn(new Point2D.Double(0, 0));
|
||||
when(diode1.isControlPointSticky(0)).thenReturn(true);
|
||||
when(diode1.isControlPointSticky(1)).thenReturn(true);
|
||||
when(diode1.isPolarized()).thenReturn(true);
|
||||
when(diode1.toString()).thenReturn("Diode1");
|
||||
when(diode1.getControlPointNodeName(0)).thenReturn("Anode");
|
||||
when(diode1.getControlPointNodeName(1)).thenReturn("Cathode");
|
||||
@@ -251,6 +238,7 @@ public class CompareServiceTest {
|
||||
when(component2_1.getControlPoint(0)).thenReturn(new Point2D.Double(0, 0));
|
||||
when(component2_1.isControlPointSticky(0)).thenReturn(true);
|
||||
when(component2_1.toString()).thenReturn("Component2");
|
||||
when(component2_1.isPolarized()).thenReturn(false);
|
||||
|
||||
// Create Component3 for netlist1
|
||||
IDIYComponent<?> component3_1 = mock(IDIYComponent.class);
|
||||
@@ -260,10 +248,8 @@ public class CompareServiceTest {
|
||||
when(component3_1.getControlPoint(0)).thenReturn(new Point2D.Double(0, 0));
|
||||
when(component3_1.isControlPointSticky(0)).thenReturn(true);
|
||||
when(component3_1.toString()).thenReturn("Component3");
|
||||
when(component3_1.isPolarized()).thenReturn(false);
|
||||
|
||||
// Create first netlist with polarized component in two groups
|
||||
Netlist netlist1 = new Netlist(List.of(diode1, component2_1, component3_1));
|
||||
|
||||
// Create groups for netlist1
|
||||
Group group1 = new Group();
|
||||
Node node1 = new Node(diode1, 0); // Anode
|
||||
@@ -279,6 +265,9 @@ public class CompareServiceTest {
|
||||
group2.getNodes().add(node4);
|
||||
netlist1.add(group2);
|
||||
|
||||
// Create second netlist with same connections but different node order
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>());
|
||||
|
||||
// Create diode for netlist2
|
||||
IDIYComponent<?> diode2 = mock(IDIYComponent.class);
|
||||
when(diode2.getName()).thenReturn("Diode1");
|
||||
@@ -287,6 +276,7 @@ public class CompareServiceTest {
|
||||
when(diode2.getControlPoint(1)).thenReturn(new Point2D.Double(0, 0));
|
||||
when(diode2.isControlPointSticky(0)).thenReturn(true);
|
||||
when(diode2.isControlPointSticky(1)).thenReturn(true);
|
||||
when(diode2.isPolarized()).thenReturn(true);
|
||||
when(diode2.toString()).thenReturn("Diode1");
|
||||
when(diode2.getControlPointNodeName(0)).thenReturn("Anode");
|
||||
when(diode2.getControlPointNodeName(1)).thenReturn("Cathode");
|
||||
@@ -299,6 +289,7 @@ public class CompareServiceTest {
|
||||
when(component2_2.getControlPoint(0)).thenReturn(new Point2D.Double(0, 0));
|
||||
when(component2_2.isControlPointSticky(0)).thenReturn(true);
|
||||
when(component2_2.toString()).thenReturn("Component2");
|
||||
when(component2_2.isPolarized()).thenReturn(false);
|
||||
|
||||
// Create Component3 for netlist2
|
||||
IDIYComponent<?> component3_2 = mock(IDIYComponent.class);
|
||||
@@ -308,10 +299,8 @@ public class CompareServiceTest {
|
||||
when(component3_2.getControlPoint(0)).thenReturn(new Point2D.Double(0, 0));
|
||||
when(component3_2.isControlPointSticky(0)).thenReturn(true);
|
||||
when(component3_2.toString()).thenReturn("Component3");
|
||||
when(component3_2.isPolarized()).thenReturn(false);
|
||||
|
||||
// Create second netlist with same connections but different node order
|
||||
Netlist netlist2 = new Netlist(List.of(diode2, component2_2, component3_2));
|
||||
|
||||
// Create groups for netlist2 with swapped nodes
|
||||
Group group3 = new Group();
|
||||
Node node5 = new Node(diode2, 1); // Cathode
|
||||
@@ -333,7 +322,8 @@ public class CompareServiceTest {
|
||||
System.out.println("Group: " + g);
|
||||
for (Node n : g.getNodes()) {
|
||||
System.out.println(" Node: " + n.getComponent().getName() +
|
||||
" " + n.getComponent().getControlPointNodeName(n.getPointIndex()));
|
||||
" " + n.getComponent().getControlPointNodeName(n.getPointIndex()) +
|
||||
" (polarized: " + n.getComponent().isPolarized() + ")");
|
||||
}
|
||||
}
|
||||
System.out.println("\nNetlist2 groups:");
|
||||
@@ -341,7 +331,8 @@ public class CompareServiceTest {
|
||||
System.out.println("Group: " + g);
|
||||
for (Node n : g.getNodes()) {
|
||||
System.out.println(" Node: " + n.getComponent().getName() +
|
||||
" " + n.getComponent().getControlPointNodeName(n.getPointIndex()));
|
||||
" " + n.getComponent().getControlPointNodeName(n.getPointIndex()) +
|
||||
" (polarized: " + n.getComponent().isPolarized() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,23 +447,24 @@ public class CompareServiceTest {
|
||||
public void testCompare_MixedPolarizedAndNonPolarized() {
|
||||
Map<String, IDIYComponent<?>> componentMap = new HashMap<>();
|
||||
|
||||
// Create groups first so componentMap is populated
|
||||
Group g1a = createGroup(componentMap, "Resistor1", "Node1", "Diode1", "Anode");
|
||||
Group g1b = createGroup(componentMap, "Resistor1", "Node2", "Component3", "Node3");
|
||||
Group g1c = createGroup(componentMap, "Diode1", "Cathode", "Component4", "Node4");
|
||||
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
netlist1.add(g1a);
|
||||
netlist1.add(g1b);
|
||||
netlist1.add(g1c);
|
||||
// Create first netlist with both polarized and non-polarized components
|
||||
Netlist netlist1 = new Netlist(new ArrayList<>());
|
||||
netlist1.add(createGroup(componentMap, "Resistor1", "Node1", "Diode1", "Anode"));
|
||||
netlist1.add(createGroup(componentMap, "Resistor1", "Node2", "Component3", "Node3"));
|
||||
netlist1.add(createGroup(componentMap, "Diode1", "Cathode", "Component4", "Node4"));
|
||||
|
||||
// Same connections but different node order for non-polarized
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
// Create second netlist with same connections but different node order for non-polarized
|
||||
Netlist netlist2 = new Netlist(new ArrayList<>());
|
||||
netlist2.add(createGroup(componentMap, "Resistor1", "Node2", "Diode1", "Anode"));
|
||||
netlist2.add(createGroup(componentMap, "Resistor1", "Node1", "Component3", "Node3"));
|
||||
netlist2.add(createGroup(componentMap, "Diode1", "Cathode", "Component4", "Node4"));
|
||||
|
||||
// Make Resistor1 non-polarized and Diode1 polarized
|
||||
IDIYComponent<?> resistor = componentMap.get("Resistor1");
|
||||
IDIYComponent<?> diode = componentMap.get("Diode1");
|
||||
when(resistor.isPolarized()).thenReturn(false);
|
||||
when(diode.isPolarized()).thenReturn(true);
|
||||
|
||||
CompareResults results = compareService.compare(netlist1, netlist2);
|
||||
|
||||
assertTrue(results.matches());
|
||||
@@ -481,9 +473,8 @@ public class CompareServiceTest {
|
||||
}
|
||||
|
||||
private Netlist createNetlist(Map<String, IDIYComponent<?>> componentMap, String... componentNodePairs) {
|
||||
Group group = createGroup(componentMap, componentNodePairs);
|
||||
Netlist netlist = new Netlist(new ArrayList<>(componentMap.values()));
|
||||
netlist.add(group);
|
||||
Netlist netlist = new Netlist(new ArrayList<>());
|
||||
netlist.add(createGroup(componentMap, componentNodePairs));
|
||||
return netlist;
|
||||
}
|
||||
|
||||
@@ -502,6 +493,8 @@ public class CompareServiceTest {
|
||||
when(c.getControlPoint(0)).thenReturn(new Point2D.Double(0, 0));
|
||||
when(c.isControlPointSticky(0)).thenReturn(true);
|
||||
when(c.toString()).thenReturn(name);
|
||||
// Default to non-polarized
|
||||
when(c.isPolarized()).thenReturn(false);
|
||||
return c;
|
||||
});
|
||||
// For the same component name, update the node name for this instance
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.presenter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.common.BlockInstantiationMode;
|
||||
import org.diylc.common.IBlockProcessor;
|
||||
import org.diylc.common.IBlockProcessor.InvalidBlockException;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.components.composite.CompositeComponent;
|
||||
import org.diylc.core.ISwitch;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.testcomponents.SwitchTestComponent;
|
||||
import org.diylc.testcomponents.TwoPointTestComponent;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Exercises {@link BuildingBlockManager#loadBlock} in both {@link BlockInstantiationMode}s (see
|
||||
* design decision D10 and section 4.4 of {@code docs/plans/composite-building-blocks.md}).
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class BuildingBlockManagerTest {
|
||||
|
||||
private static final String BLOCK_NAME = "TestBlock";
|
||||
|
||||
private IConfigurationManager<?> configManager;
|
||||
private BuildingBlockManager manager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
List<IDIYComponent<?>> storedComponents = Arrays.asList(
|
||||
new TwoPointTestComponent("R1", new Point2D.Double(0, 0), new Point2D.Double(10, 0)),
|
||||
new TwoPointTestComponent("R2", new Point2D.Double(20, 0), new Point2D.Double(30, 0)));
|
||||
Map<String, List<IDIYComponent<?>>> blocksMap = new HashMap<String, List<IDIYComponent<?>>>();
|
||||
blocksMap.put(BLOCK_NAME, storedComponents);
|
||||
|
||||
configManager = mock(IConfigurationManager.class);
|
||||
when(configManager.readObject(eq(IPlugInPort.BLOCKS_KEY), org.mockito.ArgumentMatchers.any()))
|
||||
.thenReturn(blocksMap);
|
||||
|
||||
manager = new BuildingBlockManager(configManager, null, new InstantiationManager());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void groupModeClonesEachComponentWithAFreshNameAndId() throws InvalidBlockException {
|
||||
List<IDIYComponent<?>> result =
|
||||
manager.loadBlock(BLOCK_NAME, new ArrayList<IDIYComponent<?>>(), BlockInstantiationMode.GROUP);
|
||||
|
||||
assertEquals(2, result.size());
|
||||
// group mode always assigns fresh, project-unique names (pre-existing behavior, unchanged)
|
||||
assertEquals("TP1", result.get(0).getName());
|
||||
assertEquals("TP2", result.get(1).getName());
|
||||
assertNotEquals(result.get(0).getId(), result.get(1).getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compositeModeWrapsChildrenInASingleComponent() throws InvalidBlockException {
|
||||
List<IDIYComponent<?>> result =
|
||||
manager.loadBlock(BLOCK_NAME, new ArrayList<IDIYComponent<?>>(), BlockInstantiationMode.COMPOSITE);
|
||||
|
||||
assertEquals(1, result.size());
|
||||
assertTrue(result.get(0) instanceof CompositeComponent);
|
||||
CompositeComponent composite = (CompositeComponent) result.get(0);
|
||||
|
||||
assertEquals(BLOCK_NAME, composite.getBlockName());
|
||||
assertEquals("BLK1", composite.getName());
|
||||
assertEquals(4, composite.getControlPointCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compositeModePreservesChildNamesUnlikeGroupMode() throws InvalidBlockException {
|
||||
List<IDIYComponent<?>> result =
|
||||
manager.loadBlock(BLOCK_NAME, new ArrayList<IDIYComponent<?>>(), BlockInstantiationMode.COMPOSITE);
|
||||
CompositeComponent composite = (CompositeComponent) result.get(0);
|
||||
|
||||
// children are namespaced under the composite's own name in the netlist, so their saved
|
||||
// names must survive untouched
|
||||
assertEquals("R1", composite.getChildComponents().get(0).getName());
|
||||
assertEquals("R2", composite.getChildComponents().get(1).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compositeModeGivesEachInstanceItsOwnNameButChildrenStayIdenticallyNamed()
|
||||
throws InvalidBlockException {
|
||||
List<IDIYComponent<?>> existing = new ArrayList<IDIYComponent<?>>();
|
||||
CompositeComponent first = (CompositeComponent) manager
|
||||
.loadBlock(BLOCK_NAME, existing, BlockInstantiationMode.COMPOSITE).get(0);
|
||||
existing.add(first);
|
||||
|
||||
CompositeComponent second = (CompositeComponent) manager
|
||||
.loadBlock(BLOCK_NAME, existing, BlockInstantiationMode.COMPOSITE).get(0);
|
||||
|
||||
assertNotEquals(first.getName(), second.getName());
|
||||
assertEquals(first.getChildComponents().get(0).getName(), second.getChildComponents().get(0).getName());
|
||||
// but the underlying child components must be distinct objects with distinct ids
|
||||
assertNotEquals(first.getChildComponents().get(0).getId(), second.getChildComponents().get(0).getId());
|
||||
}
|
||||
|
||||
@Test(expected = InvalidBlockException.class)
|
||||
public void groupModeThrowsOnUnknownBlock() throws InvalidBlockException {
|
||||
manager.loadBlock("NoSuchBlock", new ArrayList<IDIYComponent<?>>(), BlockInstantiationMode.GROUP);
|
||||
}
|
||||
|
||||
@Test(expected = InvalidBlockException.class)
|
||||
public void compositeModeThrowsOnUnknownBlock() throws InvalidBlockException {
|
||||
manager.loadBlock("NoSuchBlock", new ArrayList<IDIYComponent<?>>(), BlockInstantiationMode.COMPOSITE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteBlockAlsoStripsItFromTheRecentlyUsedList() {
|
||||
List<String> recent = new ArrayList<String>(Arrays.asList(
|
||||
IBlockProcessor.BLOCK_PREFIX + BLOCK_NAME, "org.diylc.components.SomeComponent"));
|
||||
when(configManager.readObject(eq(IPlugInPort.RECENT_COMPONENTS_KEY),
|
||||
org.mockito.ArgumentMatchers.any())).thenReturn(recent);
|
||||
|
||||
manager.deleteBlock(BLOCK_NAME);
|
||||
|
||||
assertFalse(recent.contains(IBlockProcessor.BLOCK_PREFIX + BLOCK_NAME));
|
||||
assertTrue(recent.contains("org.diylc.components.SomeComponent"));
|
||||
verify(configManager).writeValue(eq(IPlugInPort.RECENT_COMPONENTS_KEY), eq(recent));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compositeModeToleratesAnInternalSwitchWithoutFailing() throws InvalidBlockException {
|
||||
// Design decision D6: the composite is not ISwitch, so a block containing a switch must
|
||||
// still place successfully - it just won't switch (see BuildingBlockManager's log warning).
|
||||
List<IDIYComponent<?>> storedComponents = Arrays.<IDIYComponent<?>>asList(new SwitchTestComponent("SW1"));
|
||||
Map<String, List<IDIYComponent<?>>> blocksMap = new HashMap<String, List<IDIYComponent<?>>>();
|
||||
blocksMap.put("SwitchBlock", storedComponents);
|
||||
when(configManager.readObject(eq(IPlugInPort.BLOCKS_KEY), org.mockito.ArgumentMatchers.any()))
|
||||
.thenReturn(blocksMap);
|
||||
|
||||
List<IDIYComponent<?>> result = manager.loadBlock("SwitchBlock", new ArrayList<IDIYComponent<?>>(),
|
||||
BlockInstantiationMode.COMPOSITE);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.size());
|
||||
assertTrue(((CompositeComponent) result.get(0)).getChildComponents().get(0) instanceof ISwitch);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package org.diylc.presenter;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -143,116 +142,4 @@ public class CalcUtilsTest {
|
||||
point2.setLocation(10.0, 21.0);
|
||||
assertFalse(CalcUtils.pointsMatch(point1, point2, 0.5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateLuminance() {
|
||||
// Test pure black
|
||||
assertEquals(0.0, CalcUtils.calculateLuminance(Color.BLACK), 0.001);
|
||||
|
||||
// Test pure white
|
||||
assertEquals(255.0, CalcUtils.calculateLuminance(Color.WHITE), 0.001);
|
||||
|
||||
// Test pure red
|
||||
double redLuminance = CalcUtils.calculateLuminance(Color.RED);
|
||||
assertEquals(76.245, redLuminance, 0.001); // 0.299 * 255
|
||||
|
||||
// Test pure green
|
||||
double greenLuminance = CalcUtils.calculateLuminance(Color.GREEN);
|
||||
assertEquals(149.685, greenLuminance, 0.001); // 0.587 * 255
|
||||
|
||||
// Test pure blue
|
||||
double blueLuminance = CalcUtils.calculateLuminance(Color.BLUE);
|
||||
assertEquals(29.07, blueLuminance, 0.001); // 0.114 * 255
|
||||
|
||||
// Test middle gray (128, 128, 128)
|
||||
Color gray = new Color(128, 128, 128);
|
||||
double grayLuminance = CalcUtils.calculateLuminance(gray);
|
||||
assertEquals(128.0, grayLuminance, 0.001);
|
||||
|
||||
// Test null color
|
||||
assertEquals(0.0, CalcUtils.calculateLuminance(null), 0.001);
|
||||
|
||||
// Test custom color
|
||||
Color custom = new Color(100, 150, 200);
|
||||
double customLuminance = CalcUtils.calculateLuminance(custom);
|
||||
double expected = 0.299 * 100 + 0.587 * 150 + 0.114 * 200;
|
||||
assertEquals(expected, customLuminance, 0.001);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertToMonochrome() {
|
||||
// Test pure black -> should stay black
|
||||
Color result = CalcUtils.convertToMonochrome(Color.BLACK);
|
||||
assertEquals(Color.BLACK, result);
|
||||
|
||||
// Test pure white -> should stay white
|
||||
result = CalcUtils.convertToMonochrome(Color.WHITE);
|
||||
assertEquals(Color.WHITE, result);
|
||||
|
||||
// Test dark color -> should become black
|
||||
Color darkBlue = new Color(0, 0, 50);
|
||||
result = CalcUtils.convertToMonochrome(darkBlue);
|
||||
assertEquals(Color.BLACK, result);
|
||||
|
||||
// Test light color -> should become white
|
||||
Color lightYellow = new Color(255, 255, 200);
|
||||
result = CalcUtils.convertToMonochrome(lightYellow);
|
||||
assertEquals(Color.WHITE, result);
|
||||
|
||||
// Test middle gray -> should become white (threshold is 128, gray is exactly 128)
|
||||
Color gray = new Color(128, 128, 128);
|
||||
result = CalcUtils.convertToMonochrome(gray);
|
||||
assertEquals(Color.WHITE, result);
|
||||
|
||||
// Test color just below threshold -> should become black
|
||||
Color darkGray = new Color(127, 127, 127);
|
||||
result = CalcUtils.convertToMonochrome(darkGray);
|
||||
assertEquals(Color.BLACK, result);
|
||||
|
||||
// Test color just above threshold -> should become white
|
||||
Color lightGray = new Color(129, 129, 129);
|
||||
result = CalcUtils.convertToMonochrome(lightGray);
|
||||
assertEquals(Color.WHITE, result);
|
||||
|
||||
// Test with custom threshold
|
||||
Color mediumColor = new Color(100, 100, 100);
|
||||
result = CalcUtils.convertToMonochrome(mediumColor, 50.0);
|
||||
assertEquals(Color.WHITE, result); // Luminance ~100, threshold 50, so white
|
||||
|
||||
result = CalcUtils.convertToMonochrome(mediumColor, 150.0);
|
||||
assertEquals(Color.BLACK, result); // Luminance ~100, threshold 150, so black
|
||||
|
||||
// Test null color
|
||||
assertNull(CalcUtils.convertToMonochrome(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertToMonochromeWithAlpha() {
|
||||
// Test color with alpha channel - alpha should be preserved
|
||||
// Red (255, 0, 0) has luminance ~76, which is < 128, so it becomes BLACK
|
||||
Color transparentRed = new Color(255, 0, 0, 128);
|
||||
Color result = CalcUtils.convertToMonochrome(transparentRed);
|
||||
assertEquals(Color.BLACK.getRed(), result.getRed());
|
||||
assertEquals(Color.BLACK.getGreen(), result.getGreen());
|
||||
assertEquals(Color.BLACK.getBlue(), result.getBlue());
|
||||
assertEquals(128, result.getAlpha());
|
||||
|
||||
// Test light color with alpha - should become WHITE
|
||||
Color transparentLight = new Color(255, 255, 200, 128);
|
||||
result = CalcUtils.convertToMonochrome(transparentLight);
|
||||
assertEquals(Color.WHITE.getRed(), result.getRed());
|
||||
assertEquals(Color.WHITE.getGreen(), result.getGreen());
|
||||
assertEquals(Color.WHITE.getBlue(), result.getBlue());
|
||||
assertEquals(128, result.getAlpha());
|
||||
|
||||
// Test fully transparent color
|
||||
Color transparent = new Color(100, 150, 200, 0);
|
||||
result = CalcUtils.convertToMonochrome(transparent);
|
||||
assertEquals(0, result.getAlpha());
|
||||
|
||||
// Test opaque color - alpha should remain 255
|
||||
Color opaque = new Color(50, 50, 50);
|
||||
result = CalcUtils.convertToMonochrome(opaque);
|
||||
assertEquals(255, result.getAlpha());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,532 +0,0 @@
|
||||
package org.diylc.presenter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.core.BoardUndersideDisplay;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IBoard;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.testcomponents.MockDIYComponent;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DrawingManagerTest {
|
||||
|
||||
@ComponentDescriptor(name = "MockBoard", author = "test", category = "Boards", instanceNamePrefix = "B",
|
||||
description = "Mock board for testing", zOrder = IDIYComponent.BOARD)
|
||||
public static class MockBoard extends MockDIYComponent implements IBoard {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Rectangle2D boardRectangle = new Rectangle2D.Double(100, 100, 200, 300);
|
||||
private BoardUndersideDisplay undersideDisplay = BoardUndersideDisplay.BELOW;
|
||||
private Size undersideOffset = new Size(20.0, SizeUnit.px);
|
||||
private Boolean undersideTransparency = Boolean.TRUE;
|
||||
|
||||
public List<AffineTransform> capturedTransforms = new ArrayList<>();
|
||||
public List<Float> capturedAlphas = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Rectangle2D getBoardRectangle() {
|
||||
return boardRectangle;
|
||||
}
|
||||
|
||||
public void setBoardRectangle(Rectangle2D boardRectangle) {
|
||||
this.boardRectangle = boardRectangle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoardUndersideDisplay getUndersideDisplay() {
|
||||
return undersideDisplay;
|
||||
}
|
||||
|
||||
public void setUndersideDisplay(BoardUndersideDisplay undersideDisplay) {
|
||||
this.undersideDisplay = undersideDisplay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Size getUndersideOffset() {
|
||||
return undersideOffset;
|
||||
}
|
||||
|
||||
public void setUndersideOffset(Size undersideOffset) {
|
||||
this.undersideOffset = undersideOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getUndersideTransparency() {
|
||||
return undersideTransparency;
|
||||
}
|
||||
|
||||
public void setUndersideTransparency(Boolean undersideTransparency) {
|
||||
this.undersideTransparency = undersideTransparency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExportToGerber() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
capturedTransforms.add(new AffineTransform(g2d.getTransform()));
|
||||
if (g2d.getComposite() instanceof AlphaComposite) {
|
||||
capturedAlphas.add(((AlphaComposite) g2d.getComposite()).getAlpha());
|
||||
} else {
|
||||
capturedAlphas.add(1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class TransformTrackingComponent extends MockDIYComponent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public List<AffineTransform> capturedTransforms = new ArrayList<>();
|
||||
public List<Float> capturedAlphas = new ArrayList<>();
|
||||
private Point2D controlPoint = new Point2D.Double(150, 150);
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
return controlPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
capturedTransforms.add(new AffineTransform(g2d.getTransform()));
|
||||
if (g2d.getComposite() instanceof AlphaComposite) {
|
||||
capturedAlphas.add(((AlphaComposite) g2d.getComposite()).getAlpha());
|
||||
} else {
|
||||
capturedAlphas.add(1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DrawingManager createDrawingManager() {
|
||||
return new DrawingManager(new MessageDispatcher<EventType>(false), InMemoryConfigurationManager.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMirrorBelow() {
|
||||
Project project = new Project();
|
||||
MockBoard board = new MockBoard();
|
||||
board.setBoardRectangle(new Rectangle2D.Double(100, 100, 200, 300));
|
||||
board.setUndersideDisplay(BoardUndersideDisplay.BELOW);
|
||||
board.setUndersideOffset(new Size(20.0, SizeUnit.px));
|
||||
board.setUndersideTransparency(true);
|
||||
|
||||
TransformTrackingComponent component = new TransformTrackingComponent();
|
||||
project.getComponents().add(board);
|
||||
project.getComponents().add(component);
|
||||
|
||||
DrawingManager drawingManager = createDrawingManager();
|
||||
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = img.createGraphics();
|
||||
|
||||
drawingManager.drawProject(g2d, project, EnumSet.of(DrawOption.ZOOM), null, null,
|
||||
Collections.emptyList(), Collections.emptySet(), Collections.emptySet(), null, null, false, 1.0, 1.0, null);
|
||||
|
||||
g2d.dispose();
|
||||
|
||||
// The component should be drawn twice: once normally and once mirrored
|
||||
assertEquals(2, component.capturedTransforms.size());
|
||||
|
||||
// Original drawing: identity / no reflection
|
||||
AffineTransform normalTx = component.capturedTransforms.get(0);
|
||||
Point2D p = new Point2D.Double(150, 150);
|
||||
Point2D normalP = normalTx.transform(p, null);
|
||||
assertEquals(150.0, normalP.getX(), 0.001);
|
||||
assertEquals(150.0, normalP.getY(), 0.001);
|
||||
|
||||
// Mirrored drawing: BELOW reflection across Y = maxY + offset/2 = 400 + 10 = 410
|
||||
// Expected y' = 2 * 410 - 150 = 820 - 150 = 670
|
||||
AffineTransform mirrorTx = component.capturedTransforms.get(1);
|
||||
Point2D mirroredP = mirrorTx.transform(p, null);
|
||||
assertEquals(150.0, mirroredP.getX(), 0.001);
|
||||
assertEquals(670.0, mirroredP.getY(), 0.001);
|
||||
|
||||
// Check transparency
|
||||
assertEquals(2, component.capturedAlphas.size());
|
||||
assertEquals(1.0f, component.capturedAlphas.get(0), 0.01f);
|
||||
assertEquals(0.5f, component.capturedAlphas.get(1), 0.01f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMirrorAbove() {
|
||||
Project project = new Project();
|
||||
MockBoard board = new MockBoard();
|
||||
board.setBoardRectangle(new Rectangle2D.Double(100, 100, 200, 300));
|
||||
board.setUndersideDisplay(BoardUndersideDisplay.ABOVE);
|
||||
board.setUndersideOffset(new Size(40.0, SizeUnit.px));
|
||||
board.setUndersideTransparency(false);
|
||||
|
||||
TransformTrackingComponent component = new TransformTrackingComponent();
|
||||
project.getComponents().add(board);
|
||||
project.getComponents().add(component);
|
||||
|
||||
DrawingManager drawingManager = createDrawingManager();
|
||||
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = img.createGraphics();
|
||||
|
||||
drawingManager.drawProject(g2d, project, EnumSet.of(DrawOption.ZOOM), null, null,
|
||||
Collections.emptyList(), Collections.emptySet(), Collections.emptySet(), null, null, false, 1.0, 1.0, null);
|
||||
|
||||
g2d.dispose();
|
||||
|
||||
assertEquals(2, component.capturedTransforms.size());
|
||||
|
||||
// Mirrored drawing: ABOVE reflection across Y = minY - offset/2 = 100 - 20 = 80
|
||||
// Expected y' = 2 * 80 - 150 = 160 - 150 = 10
|
||||
AffineTransform mirrorTx = component.capturedTransforms.get(1);
|
||||
Point2D mirroredP = mirrorTx.transform(new Point2D.Double(150, 150), null);
|
||||
assertEquals(150.0, mirroredP.getX(), 0.001);
|
||||
assertEquals(10.0, mirroredP.getY(), 0.001);
|
||||
|
||||
// Transparency should not be 0.5 when undersideTransparency is false
|
||||
assertEquals(1.0f, component.capturedAlphas.get(1), 0.01f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMirrorLeft() {
|
||||
Project project = new Project();
|
||||
MockBoard board = new MockBoard();
|
||||
board.setBoardRectangle(new Rectangle2D.Double(100, 100, 200, 300));
|
||||
board.setUndersideDisplay(BoardUndersideDisplay.LEFT);
|
||||
board.setUndersideOffset(new Size(20.0, SizeUnit.px));
|
||||
|
||||
TransformTrackingComponent component = new TransformTrackingComponent();
|
||||
project.getComponents().add(board);
|
||||
project.getComponents().add(component);
|
||||
|
||||
DrawingManager drawingManager = createDrawingManager();
|
||||
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = img.createGraphics();
|
||||
|
||||
drawingManager.drawProject(g2d, project, EnumSet.of(DrawOption.ZOOM), null, null,
|
||||
Collections.emptyList(), Collections.emptySet(), Collections.emptySet(), null, null, false, 1.0, 1.0, null);
|
||||
|
||||
g2d.dispose();
|
||||
|
||||
assertEquals(2, component.capturedTransforms.size());
|
||||
|
||||
// Mirrored drawing: LEFT reflection across X = minX - offset/2 = 100 - 10 = 90
|
||||
// Expected x' = 2 * 90 - 150 = 180 - 150 = 30
|
||||
AffineTransform mirrorTx = component.capturedTransforms.get(1);
|
||||
Point2D mirroredP = mirrorTx.transform(new Point2D.Double(150, 150), null);
|
||||
assertEquals(30.0, mirroredP.getX(), 0.001);
|
||||
assertEquals(150.0, mirroredP.getY(), 0.001);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMirrorRight() {
|
||||
Project project = new Project();
|
||||
MockBoard board = new MockBoard();
|
||||
board.setBoardRectangle(new Rectangle2D.Double(100, 100, 200, 300));
|
||||
board.setUndersideDisplay(BoardUndersideDisplay.RIGHT);
|
||||
board.setUndersideOffset(new Size(20.0, SizeUnit.px));
|
||||
|
||||
TransformTrackingComponent component = new TransformTrackingComponent();
|
||||
project.getComponents().add(board);
|
||||
project.getComponents().add(component);
|
||||
|
||||
DrawingManager drawingManager = createDrawingManager();
|
||||
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = img.createGraphics();
|
||||
|
||||
drawingManager.drawProject(g2d, project, EnumSet.of(DrawOption.ZOOM), null, null,
|
||||
Collections.emptyList(), Collections.emptySet(), Collections.emptySet(), null, null, false, 1.0, 1.0, null);
|
||||
|
||||
g2d.dispose();
|
||||
|
||||
assertEquals(2, component.capturedTransforms.size());
|
||||
|
||||
// Mirrored drawing: RIGHT reflection across X = maxX + offset/2 = 300 + 10 = 310
|
||||
// Expected x' = 2 * 310 - 150 = 620 - 150 = 470
|
||||
AffineTransform mirrorTx = component.capturedTransforms.get(1);
|
||||
Point2D mirroredP = mirrorTx.transform(new Point2D.Double(150, 150), null);
|
||||
assertEquals(470.0, mirroredP.getX(), 0.001);
|
||||
assertEquals(150.0, mirroredP.getY(), 0.001);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUndersideDisplayNone() {
|
||||
Project project = new Project();
|
||||
MockBoard board = new MockBoard();
|
||||
board.setUndersideDisplay(BoardUndersideDisplay.NONE);
|
||||
|
||||
TransformTrackingComponent component = new TransformTrackingComponent();
|
||||
project.getComponents().add(board);
|
||||
project.getComponents().add(component);
|
||||
|
||||
DrawingManager drawingManager = createDrawingManager();
|
||||
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = img.createGraphics();
|
||||
|
||||
drawingManager.drawProject(g2d, project, EnumSet.of(DrawOption.ZOOM), null, null,
|
||||
Collections.emptyList(), Collections.emptySet(), Collections.emptySet(), null, null, false, 1.0, 1.0, null);
|
||||
|
||||
g2d.dispose();
|
||||
|
||||
// No mirrored drawing
|
||||
assertEquals(1, component.capturedTransforms.size());
|
||||
assertEquals(1, board.capturedTransforms.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextUnmirroringHorizontal() {
|
||||
BufferedImage img = new BufferedImage(500, 500, BufferedImage.TYPE_INT_ARGB);
|
||||
final List<AffineTransform> capturedDuringDrawString = new ArrayList<>();
|
||||
Graphics2D canvasG2d = new Graphics2DProxy(img.createGraphics()) {
|
||||
@Override
|
||||
public void drawString(String str, int x, int y) {
|
||||
capturedDuringDrawString.add(new AffineTransform(getTransform()));
|
||||
super.drawString(str, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawString(String str, float x, float y) {
|
||||
capturedDuringDrawString.add(new AffineTransform(getTransform()));
|
||||
super.drawString(str, x, y);
|
||||
}
|
||||
};
|
||||
|
||||
G2DWrapper wrapper = new G2DWrapper(canvasG2d, 1.0, EnumSet.noneOf(DrawOption.class));
|
||||
|
||||
// Simulate horizontal mirror mode
|
||||
wrapper.setMirrorDirection(G2DWrapper.MirrorDirection.HORIZONTAL);
|
||||
AffineTransform mirrorTx = new AffineTransform();
|
||||
mirrorTx.translate(300, 0);
|
||||
mirrorTx.scale(-1.0, 1.0);
|
||||
mirrorTx.translate(-300, 0);
|
||||
wrapper.transform(mirrorTx);
|
||||
|
||||
wrapper.drawString("10K Log", 200, 200);
|
||||
|
||||
assertEquals(1, capturedDuringDrawString.size());
|
||||
AffineTransform textTx = capturedDuringDrawString.get(0);
|
||||
|
||||
// The determinant should be positive (un-mirrored / right-reading text)
|
||||
assertTrue("Text transform determinant should be positive (not mirrored)", textTx.getDeterminant() > 0);
|
||||
|
||||
// After drawing, wrapper transform should still be the mirrorTx
|
||||
assertEquals(-1.0, wrapper.getTransform().getScaleX(), 0.001);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextUnmirroringVertical() {
|
||||
BufferedImage img = new BufferedImage(500, 500, BufferedImage.TYPE_INT_ARGB);
|
||||
final List<AffineTransform> capturedDuringDrawString = new ArrayList<>();
|
||||
Graphics2D canvasG2d = new Graphics2DProxy(img.createGraphics()) {
|
||||
@Override
|
||||
public void drawString(String str, int x, int y) {
|
||||
capturedDuringDrawString.add(new AffineTransform(getTransform()));
|
||||
super.drawString(str, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawString(String str, float x, float y) {
|
||||
capturedDuringDrawString.add(new AffineTransform(getTransform()));
|
||||
super.drawString(str, x, y);
|
||||
}
|
||||
};
|
||||
|
||||
G2DWrapper wrapper = new G2DWrapper(canvasG2d, 1.0, EnumSet.noneOf(DrawOption.class));
|
||||
|
||||
// Simulate vertical mirror mode
|
||||
wrapper.setMirrorDirection(G2DWrapper.MirrorDirection.VERTICAL);
|
||||
AffineTransform mirrorTx = new AffineTransform();
|
||||
mirrorTx.translate(0, 300);
|
||||
mirrorTx.scale(1.0, -1.0);
|
||||
mirrorTx.translate(0, -300);
|
||||
wrapper.transform(mirrorTx);
|
||||
|
||||
wrapper.drawString("47uF", 200, 200);
|
||||
|
||||
assertEquals(1, capturedDuringDrawString.size());
|
||||
AffineTransform textTx = capturedDuringDrawString.get(0);
|
||||
|
||||
// The determinant should be positive (un-mirrored / right-reading text)
|
||||
assertTrue("Text transform determinant should be positive (not mirrored)", textTx.getDeterminant() > 0);
|
||||
|
||||
// After drawing, wrapper transform should still be the mirrorTx
|
||||
assertEquals(-1.0, wrapper.getTransform().getScaleY(), 0.001);
|
||||
}
|
||||
|
||||
// Simple delegating Graphics2D proxy for testing
|
||||
private static class Graphics2DProxy extends Graphics2D {
|
||||
private final Graphics2D delegate;
|
||||
|
||||
public Graphics2DProxy(Graphics2D delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(java.awt.Shape s) { delegate.draw(s); }
|
||||
@Override
|
||||
public boolean drawImage(java.awt.Image img, AffineTransform xform, java.awt.image.ImageObserver obs) { return delegate.drawImage(img, xform, obs); }
|
||||
@Override
|
||||
public void drawImage(BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y) { delegate.drawImage(img, op, x, y); }
|
||||
@Override
|
||||
public void drawRenderedImage(java.awt.image.RenderedImage img, AffineTransform xform) { delegate.drawRenderedImage(img, xform); }
|
||||
@Override
|
||||
public void drawRenderableImage(java.awt.image.renderable.RenderableImage img, AffineTransform xform) { delegate.drawRenderableImage(img, xform); }
|
||||
@Override
|
||||
public void drawString(String str, int x, int y) { delegate.drawString(str, x, y); }
|
||||
@Override
|
||||
public void drawString(String str, float x, float y) { delegate.drawString(str, x, y); }
|
||||
@Override
|
||||
public void drawString(java.text.AttributedCharacterIterator iterator, int x, int y) { delegate.drawString(iterator, x, y); }
|
||||
@Override
|
||||
public void drawString(java.text.AttributedCharacterIterator iterator, float x, float y) { delegate.drawString(iterator, x, y); }
|
||||
@Override
|
||||
public void drawGlyphVector(java.awt.font.GlyphVector g, float x, float y) { delegate.drawGlyphVector(g, x, y); }
|
||||
@Override
|
||||
public void fill(java.awt.Shape s) { delegate.fill(s); }
|
||||
@Override
|
||||
public boolean hit(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke) { return delegate.hit(rect, s, onStroke); }
|
||||
@Override
|
||||
public java.awt.GraphicsConfiguration getDeviceConfiguration() { return delegate.getDeviceConfiguration(); }
|
||||
@Override
|
||||
public void setComposite(java.awt.Composite comp) { delegate.setComposite(comp); }
|
||||
@Override
|
||||
public void setPaint(java.awt.Paint paint) { delegate.setPaint(paint); }
|
||||
@Override
|
||||
public void setStroke(java.awt.Stroke s) { delegate.setStroke(s); }
|
||||
@Override
|
||||
public void setRenderingHint(java.awt.RenderingHints.Key hintKey, Object hintValue) { delegate.setRenderingHint(hintKey, hintValue); }
|
||||
@Override
|
||||
public Object getRenderingHint(java.awt.RenderingHints.Key hintKey) { return delegate.getRenderingHint(hintKey); }
|
||||
@Override
|
||||
public void setRenderingHints(java.util.Map<?, ?> hints) { delegate.setRenderingHints(hints); }
|
||||
@Override
|
||||
public void addRenderingHints(java.util.Map<?, ?> hints) { delegate.addRenderingHints(hints); }
|
||||
@Override
|
||||
public java.awt.RenderingHints getRenderingHints() { return delegate.getRenderingHints(); }
|
||||
@Override
|
||||
public void translate(int x, int y) { delegate.translate(x, y); }
|
||||
@Override
|
||||
public void translate(double tx, double ty) { delegate.translate(tx, ty); }
|
||||
@Override
|
||||
public void rotate(double theta) { delegate.rotate(theta); }
|
||||
@Override
|
||||
public void rotate(double theta, double x, double y) { delegate.rotate(theta, x, y); }
|
||||
@Override
|
||||
public void scale(double sx, double sy) { delegate.scale(sx, sy); }
|
||||
@Override
|
||||
public void shear(double shx, double shy) { delegate.shear(shx, shy); }
|
||||
@Override
|
||||
public void transform(AffineTransform Tx) { delegate.transform(Tx); }
|
||||
@Override
|
||||
public void setTransform(AffineTransform Tx) { delegate.setTransform(Tx); }
|
||||
@Override
|
||||
public AffineTransform getTransform() { return delegate.getTransform(); }
|
||||
@Override
|
||||
public java.awt.Paint getPaint() { return delegate.getPaint(); }
|
||||
@Override
|
||||
public java.awt.Composite getComposite() { return delegate.getComposite(); }
|
||||
@Override
|
||||
public void setBackground(java.awt.Color color) { delegate.setBackground(color); }
|
||||
@Override
|
||||
public java.awt.Color getBackground() { return delegate.getBackground(); }
|
||||
@Override
|
||||
public java.awt.Stroke getStroke() { return delegate.getStroke(); }
|
||||
@Override
|
||||
public void clip(java.awt.Shape s) { delegate.clip(s); }
|
||||
@Override
|
||||
public java.awt.font.FontRenderContext getFontRenderContext() { return delegate.getFontRenderContext(); }
|
||||
@Override
|
||||
public java.awt.Graphics create() { return delegate.create(); }
|
||||
@Override
|
||||
public java.awt.Color getColor() { return delegate.getColor(); }
|
||||
@Override
|
||||
public void setColor(java.awt.Color c) { delegate.setColor(c); }
|
||||
@Override
|
||||
public void setPaintMode() { delegate.setPaintMode(); }
|
||||
@Override
|
||||
public void setXORMode(java.awt.Color c1) { delegate.setXORMode(c1); }
|
||||
@Override
|
||||
public java.awt.Font getFont() { return delegate.getFont(); }
|
||||
@Override
|
||||
public void setFont(java.awt.Font font) { delegate.setFont(font); }
|
||||
@Override
|
||||
public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { return delegate.getFontMetrics(f); }
|
||||
@Override
|
||||
public java.awt.Rectangle getClipBounds() { return delegate.getClipBounds(); }
|
||||
@Override
|
||||
public void clipRect(int x, int y, int width, int height) { delegate.clipRect(x, y, width, height); }
|
||||
@Override
|
||||
public void setClip(int x, int y, int width, int height) { delegate.setClip(x, y, width, height); }
|
||||
@Override
|
||||
public java.awt.Shape getClip() { return delegate.getClip(); }
|
||||
@Override
|
||||
public void setClip(java.awt.Shape clip) { delegate.setClip(clip); }
|
||||
@Override
|
||||
public void copyArea(int x, int y, int width, int height, int dx, int dy) { delegate.copyArea(x, y, width, height, dx, dy); }
|
||||
@Override
|
||||
public void drawLine(int x1, int y1, int x2, int y2) { delegate.drawLine(x1, y1, x2, y2); }
|
||||
@Override
|
||||
public void fillRect(int x, int y, int width, int height) { delegate.fillRect(x, y, width, height); }
|
||||
@Override
|
||||
public void clearRect(int x, int y, int width, int height) { delegate.clearRect(x, y, width, height); }
|
||||
@Override
|
||||
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { delegate.drawRoundRect(x, y, width, height, arcWidth, arcHeight); }
|
||||
@Override
|
||||
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { delegate.fillRoundRect(x, y, width, height, arcWidth, arcHeight); }
|
||||
@Override
|
||||
public void drawOval(int x, int y, int width, int height) { delegate.drawOval(x, y, width, height); }
|
||||
@Override
|
||||
public void fillOval(int x, int y, int width, int height) { delegate.fillOval(x, y, width, height); }
|
||||
@Override
|
||||
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { delegate.drawArc(x, y, width, height, startAngle, arcAngle); }
|
||||
@Override
|
||||
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { delegate.fillArc(x, y, width, height, startAngle, arcAngle); }
|
||||
@Override
|
||||
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) { delegate.drawPolyline(xPoints, yPoints, nPoints); }
|
||||
@Override
|
||||
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) { delegate.drawPolygon(xPoints, yPoints, nPoints); }
|
||||
@Override
|
||||
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) { delegate.fillPolygon(xPoints, yPoints, nPoints); }
|
||||
@Override
|
||||
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer) { return delegate.drawImage(img, x, y, observer); }
|
||||
@Override
|
||||
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer) { return delegate.drawImage(img, x, y, width, height, observer); }
|
||||
@Override
|
||||
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer) { return delegate.drawImage(img, x, y, bgcolor, observer); }
|
||||
@Override
|
||||
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer) { return delegate.drawImage(img, x, y, width, height, bgcolor, observer); }
|
||||
@Override
|
||||
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer) { return delegate.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer); }
|
||||
@Override
|
||||
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer) { return delegate.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer); }
|
||||
@Override
|
||||
public void dispose() { delegate.dispose(); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,173 +1,173 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.testcomponents;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Capacitance;
|
||||
import org.diylc.core.measures.CapacitanceUnit;
|
||||
import org.diylc.core.measures.Resistance;
|
||||
import org.diylc.core.measures.ResistanceUnit;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Mock", author = "bancika", category = "Sample", instanceNamePrefix = "M",
|
||||
description = "test", zOrder = IDIYComponent.COMPONENT)
|
||||
public class MockDIYComponent extends AbstractComponent<Capacitance> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String testField = "Hello World";
|
||||
private Capacitance c = new Capacitance(100d, CapacitanceUnit.uF);
|
||||
private Resistance r = new Resistance(123d, ResistanceUnit.K);
|
||||
private Size s = new Size(1d, SizeUnit.cm);
|
||||
private Color color = Color.green;
|
||||
private Point2D leftTopCorner = new Point(0, 0);
|
||||
private String name = "something";
|
||||
|
||||
public MockDIYComponent(String testField, Capacitance c, Resistance r, Size s, Color color, Point leftTopCorner) {
|
||||
super();
|
||||
this.testField = testField;
|
||||
this.c = c;
|
||||
this.r = r;
|
||||
this.s = s;
|
||||
this.color = color;
|
||||
this.leftTopCorner = leftTopCorner;
|
||||
}
|
||||
|
||||
public MockDIYComponent() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canControlPointOverlap(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.WHEN_SELECTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
return leftTopCorner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
leftTopCorner.setLocation(point);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Test Field")
|
||||
public String getTestField() {
|
||||
return testField;
|
||||
}
|
||||
|
||||
public void setTestField(String testField) {
|
||||
this.testField = testField;
|
||||
}
|
||||
|
||||
@EditableProperty(defaultable = true)
|
||||
public Capacitance getValue() {
|
||||
return c;
|
||||
}
|
||||
|
||||
public void setValue(Capacitance c) {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
@EditableProperty(defaultable = true)
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Resistance getR() {
|
||||
return r;
|
||||
}
|
||||
|
||||
// Setter is commented out, ClassProcessor should ignore this property.
|
||||
// public void setR(Resistance r) {
|
||||
// this.r = r;
|
||||
// }
|
||||
|
||||
// No annotation, so this property should be ignored.
|
||||
public Size getS() {
|
||||
return s;
|
||||
}
|
||||
|
||||
public void setS(Size s) {
|
||||
this.s = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setColor(componentState.equals(ComponentState.SELECTED) ? color : color.darker());
|
||||
g2d.fillRect((int) Math.round(leftTopCorner.getX()), (int) Math.round(leftTopCorner.getY()), 200, 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.drawString("X", 10, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.testcomponents;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Capacitance;
|
||||
import org.diylc.core.measures.CapacitanceUnit;
|
||||
import org.diylc.core.measures.Resistance;
|
||||
import org.diylc.core.measures.ResistanceUnit;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Mock", author = "bancika", category = "Sample", instanceNamePrefix = "M",
|
||||
description = "test", zOrder = IDIYComponent.COMPONENT)
|
||||
public class MockDIYComponent extends AbstractComponent<Capacitance> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String testField = "Hello World";
|
||||
private Capacitance c = new Capacitance(100d, CapacitanceUnit.uF);
|
||||
private Resistance r = new Resistance(123d, ResistanceUnit.K);
|
||||
private Size s = new Size(1d, SizeUnit.cm);
|
||||
private Color color = Color.green;
|
||||
private Point2D leftTopCorner = new Point(0, 0);
|
||||
private String name = "something";
|
||||
|
||||
public MockDIYComponent(String testField, Capacitance c, Resistance r, Size s, Color color, Point leftTopCorner) {
|
||||
super();
|
||||
this.testField = testField;
|
||||
this.c = c;
|
||||
this.r = r;
|
||||
this.s = s;
|
||||
this.color = color;
|
||||
this.leftTopCorner = leftTopCorner;
|
||||
}
|
||||
|
||||
public MockDIYComponent() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canControlPointOverlap(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.WHEN_SELECTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
return leftTopCorner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
leftTopCorner.setLocation(point);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Test Field")
|
||||
public String getTestField() {
|
||||
return testField;
|
||||
}
|
||||
|
||||
public void setTestField(String testField) {
|
||||
this.testField = testField;
|
||||
}
|
||||
|
||||
@EditableProperty(defaultable = true)
|
||||
public Capacitance getValue() {
|
||||
return c;
|
||||
}
|
||||
|
||||
public void setValue(Capacitance c) {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
@EditableProperty(defaultable = true)
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Resistance getR() {
|
||||
return r;
|
||||
}
|
||||
|
||||
// Setter is commented out, ClassProcessor should ignore this property.
|
||||
// public void setR(Resistance r) {
|
||||
// this.r = r;
|
||||
// }
|
||||
|
||||
// No annotation, so this property should be ignored.
|
||||
public Size getS() {
|
||||
return s;
|
||||
}
|
||||
|
||||
public void setS(Size s) {
|
||||
this.s = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setColor(componentState.equals(ComponentState.SELECTED) ? color : color.darker());
|
||||
g2d.fillRect((int)leftTopCorner.getX(), (int)leftTopCorner.getY(), 200, 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.drawString("X", 10, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.testcomponents;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.core.ISwitch;
|
||||
|
||||
/**
|
||||
* Smallest possible {@link ISwitch} implementation, used to verify that a building block
|
||||
* containing a switch can still be instantiated as a {@code CompositeComponent} (design decision
|
||||
* D6 in {@code docs/plans/composite-building-blocks.md} - the composite itself is not
|
||||
* {@code ISwitch}, so the switch places and draws but contributes no switching behavior).
|
||||
* <p>
|
||||
* Deliberately a public top-level class, not a nested one: {@link
|
||||
* org.diylc.components.AbstractComponent#clone()} instantiates the no-arg constructor via plain
|
||||
* reflection (no {@code setAccessible}), which fails across packages unless both the class and
|
||||
* the constructor are public.
|
||||
*/
|
||||
public class SwitchTestComponent extends TwoPointTestComponent implements ISwitch {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public SwitchTestComponent() {
|
||||
this("SW");
|
||||
}
|
||||
|
||||
public SwitchTestComponent(String name) {
|
||||
super(name, new Point2D.Double(0, 0), new Point2D.Double(10, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPositionCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPositionName(int position) {
|
||||
return position == 0 ? "ON" : "OFF";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean arePointsConnected(int index1, int index2, int position) {
|
||||
return position == 0;
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.testcomponents;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
|
||||
/**
|
||||
* Minimal two-point component used to exercise {@code CompositeComponent} and
|
||||
* {@code BuildingBlockManager} in tests: two control points, individually configurable
|
||||
* stickiness, node naming left at the {@link AbstractComponent} default (the 1-based point
|
||||
* index), so a composite's per-child node name delegation can be verified precisely.
|
||||
*/
|
||||
@ComponentDescriptor(name = "Two Point Test", category = "Test", author = "Test",
|
||||
description = "test", instanceNamePrefix = "TP", zOrder = IDIYComponent.COMPONENT)
|
||||
public class TwoPointTestComponent extends AbstractComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Point2D p0;
|
||||
private Point2D p1;
|
||||
private boolean sticky0 = true;
|
||||
private boolean sticky1 = true;
|
||||
|
||||
public TwoPointTestComponent() {
|
||||
this("", new Point2D.Double(0, 0), new Point2D.Double(10, 0));
|
||||
}
|
||||
|
||||
public TwoPointTestComponent(String name, Point2D p0, Point2D p1) {
|
||||
setName(name);
|
||||
this.p0 = p0;
|
||||
this.p1 = p1;
|
||||
}
|
||||
|
||||
public void setSticky(int index, boolean sticky) {
|
||||
if (index == 0)
|
||||
sticky0 = sticky;
|
||||
else
|
||||
sticky1 = sticky;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
return index == 0 ? p0 : p1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
if (index == 0)
|
||||
p0 = point;
|
||||
else
|
||||
p1 = point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return index == 0 ? sticky0 : sticky1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.ALWAYS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
}
|
||||
}
|
||||
@@ -7,15 +7,15 @@
|
||||
<parent>
|
||||
<groupId>org.diylc</groupId>
|
||||
<artifactId>diylc-parent</artifactId>
|
||||
<version>6.4.0</version>
|
||||
<version>5.7.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>diylc-library</artifactId>
|
||||
<!-- No need to specify version - it inherits from parent -->
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
@@ -71,18 +72,13 @@ public class StringUtils {
|
||||
* @return a non-empty list of strings
|
||||
*/
|
||||
public static List<String> wrap(String str, FontMetrics fm, int maxWidth) {
|
||||
// First split by actual newlines to honor them, then split by <br> tags
|
||||
List<String> lines = splitIntoLines(str);
|
||||
List<String> allLines = new ArrayList<String>();
|
||||
for (String line : lines) {
|
||||
String[] split = line.split("\\<br\\>");
|
||||
allLines.addAll(Arrays.asList(split));
|
||||
}
|
||||
if (allLines.size() == 0)
|
||||
return allLines;
|
||||
String[] split = str.split("\\<br\\>");
|
||||
List<String> lines = Arrays.stream(split).flatMap(s -> splitIntoLines(s).stream()).collect(Collectors.toList());
|
||||
if (lines.size() == 0)
|
||||
return lines;
|
||||
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
for (Iterator<String> iter = allLines.iterator(); iter.hasNext();)
|
||||
for (Iterator<String> iter = lines.iterator(); iter.hasNext();)
|
||||
wrapLineInto((String) iter.next(), strings, fm, maxWidth);
|
||||
return strings;
|
||||
}
|
||||
@@ -130,8 +126,8 @@ public class StringUtils {
|
||||
line = line.substring(pos).trim();
|
||||
len = line.length();
|
||||
}
|
||||
// Always add the line, even if empty, to preserve empty lines from newlines
|
||||
list.add(line);
|
||||
if (len > 0)
|
||||
list.add(line);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,24 +209,12 @@ public class StringUtils {
|
||||
if (text == null)
|
||||
return;
|
||||
|
||||
// Use -1 limit to preserve trailing empty strings so we can filter them out
|
||||
String[] parts = text.split("\\<br\\>", -1);
|
||||
String[] parts = text.split("\\<br\\>");
|
||||
if (parts.length > 1) {
|
||||
// Remove trailing empty strings to avoid rendering extra blank lines
|
||||
int lastNonEmpty = parts.length - 1;
|
||||
while (lastNonEmpty >= 0 && parts[lastNonEmpty].trim().isEmpty()) {
|
||||
lastNonEmpty--;
|
||||
}
|
||||
// If all parts are empty, don't render anything
|
||||
if (lastNonEmpty < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||
Rectangle stringBounds = fontMetrics.getStringBounds(parts[0], g2d).getBounds();
|
||||
int actualLength = lastNonEmpty + 1;
|
||||
for (int i = 0; i < actualLength; i++)
|
||||
drawCenteredText(g2d, parts[i], x, (int)(y - stringBounds.height * (actualLength - 1) / 2d + i * stringBounds.height), horizontalAlignment, verticalAlignment);
|
||||
for (int i = 0; i < parts.length; i++)
|
||||
drawCenteredText(g2d, parts[i], x, (int)(y - stringBounds.height * (parts.length - 1) / 2d + i * stringBounds.height), horizontalAlignment, verticalAlignment);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+29
-45
@@ -43,7 +43,12 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.LineStyle;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.core.*;
|
||||
import org.diylc.components.AbstractLabeledComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Theme;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
|
||||
import org.diylc.core.measures.Size;
|
||||
@@ -58,8 +63,7 @@ import org.diylc.utils.Constants;
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponent<T> implements
|
||||
IHaveLength {
|
||||
public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponent<T> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -165,7 +169,10 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
new Ellipse2D.Double((getFlipStanding() ? getPoints()[1] : getPoints()[0]).getX() - width / 2,
|
||||
(getFlipStanding() ? getPoints()[1] : getPoints()[0]).getY() - width / 2, width, width);
|
||||
shapeRect = body.getBounds();
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getStandingBodyColor());
|
||||
g2d.fill(body);
|
||||
g2d.setComposite(oldComposite);
|
||||
@@ -252,16 +259,19 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
g2d.translate((getPoints()[0].getX() + getPoints()[1].getX() - length) / 2, (getPoints()[0].getY() + getPoints()[1].getY() - width) / 2);
|
||||
g2d.rotate(theta, length / 2, width / 2);
|
||||
// Draw body.
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
if (getBodyColor() != null) {
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBodyColor());
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
if (bodyColor != null) {
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||
|
||||
drawingObserver.startTracking();
|
||||
|
||||
if (!outlineMode && ConfigurationManager.getInstance().readBoolean(IPlugInPort.HI_QUALITY_RENDER_KEY, false)) {
|
||||
Point2D p1 = new Point2D.Double(length / 2, 0);
|
||||
Point2D p2 = new Point2D.Double(length / 2, width);
|
||||
ShadedPaint paint = theta > 0 && theta < Math.PI ? new ShadedPaint(p2, p1, getBodyColor()) : new ShadedPaint(p1, p2, getBodyColor());
|
||||
ShadedPaint paint = theta > 0 && theta < Math.PI ? new ShadedPaint(p2, p1, bodyColor) : new ShadedPaint(p1, p2, bodyColor);
|
||||
Paint oldPaint = g2d.getPaint();
|
||||
g2d.setPaint(paint);
|
||||
g2d.fill(shape);
|
||||
@@ -293,17 +303,17 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: getBorderColor();
|
||||
: borderColor;
|
||||
}
|
||||
g2d.setColor(finalBorderColor);
|
||||
|
||||
// if we are not filling the shape with color we need to ensure that we track the outline (e.g. with schematic symbols)
|
||||
if (getBodyColor() == null)
|
||||
if (bodyColor == null)
|
||||
drawingObserver.startTracking();
|
||||
|
||||
g2d.draw(shape);
|
||||
|
||||
if (getBodyColor() == null)
|
||||
if (bodyColor == null)
|
||||
drawingObserver.stopTracking();
|
||||
|
||||
if (decorateAboveBorder()) {
|
||||
@@ -357,8 +367,8 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
offset = -offset;
|
||||
}
|
||||
|
||||
drawingObserver.startTracking();
|
||||
if (getMoveLabel()) {
|
||||
drawingObserver.startTracking();
|
||||
g2d.setTransform(oldTransform);
|
||||
g2d.translate(getPoints()[2].getX(), getPoints()[2].getY());
|
||||
if (getLabelOriantation() != LabelOriantation.Horizontal) {
|
||||
@@ -368,18 +378,19 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
g2d.setTransform(oldTransform);
|
||||
} else {
|
||||
if (isStanding() || getLabelOriantation() == LabelOriantation.Horizontal) {
|
||||
drawingObserver.startTracking();
|
||||
g2d.setTransform(oldTransform);
|
||||
double x = (getPoints()[0].getX() + getPoints()[1].getX() - length) / 2.0;
|
||||
double y = (getPoints()[0].getY() + getPoints()[1].getY() - width) / 2.0;
|
||||
g2d.drawString(label, (int) (x + (length - textRect.getWidth()) / 2 + offset),
|
||||
(int) (y + calculateLabelYOffset(shapeRect, textRect, fontMetrics)));
|
||||
} else {
|
||||
drawingObserver.stopTracking();
|
||||
g2d.drawString(label, (int) (length - textRect.getWidth()) / 2 + offset,
|
||||
calculateLabelYOffset(shapeRect, textRect, fontMetrics));
|
||||
g2d.setTransform(oldTransform);
|
||||
}
|
||||
}
|
||||
drawingObserver.stopTracking();
|
||||
}
|
||||
// if (getLabelOriantation() == LabelOriantation.Horizontal) {
|
||||
//
|
||||
@@ -423,7 +434,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
Stroke stroke = null;
|
||||
switch (getStyle()) {
|
||||
case SOLID:
|
||||
stroke = ObjectCache.getInstance().fetchStroke(thickness, getEndingStyle() == LineEndingStyle.Round ? BasicStroke.CAP_ROUND : BasicStroke.CAP_BUTT);
|
||||
stroke = ObjectCache.getInstance().fetchBasicStroke(thickness);
|
||||
break;
|
||||
case DASHED:
|
||||
stroke =
|
||||
@@ -434,7 +445,10 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
break;
|
||||
}
|
||||
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (getAlpha() < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * getAlpha() / MAX_ALPHA));
|
||||
}
|
||||
if (shouldShadeLeads()) {
|
||||
Shape lineShape = stroke.createStrokedShape(line);
|
||||
|
||||
@@ -627,32 +641,6 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Size calculateLength() {
|
||||
|
||||
try {
|
||||
Point2D[] points = getPoints();
|
||||
if (points.length < 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Calculate distance between ending points
|
||||
double distanceInPixels = points[0].distance(points[1]);
|
||||
|
||||
// Convert to Size with appropriate unit (mm or in based on configuration)
|
||||
SizeUnit unit;
|
||||
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.METRIC_KEY, true)) {
|
||||
unit = SizeUnit.mm;
|
||||
} else {
|
||||
unit = SizeUnit.in;
|
||||
}
|
||||
|
||||
return Size.fromPixels(distanceInPixels, unit);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Width", defaultable = true, validatorClass = PositiveNonZeroMeasureValidator.class, sortOrder = 102)
|
||||
public Size getWidth() {
|
||||
return width;
|
||||
@@ -759,10 +747,6 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
|
||||
hideShortLeads = false;
|
||||
return hideShortLeads;
|
||||
}
|
||||
|
||||
protected LineEndingStyle getEndingStyle() {
|
||||
return LineEndingStyle.Round;
|
||||
}
|
||||
|
||||
public void setHideShortLeads(Boolean hideShortLeads) {
|
||||
this.hideShortLeads = hideShortLeads;
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.diylc.components;
|
||||
|
||||
public enum LineEndingStyle {
|
||||
Round, Flat
|
||||
}
|
||||
@@ -88,9 +88,14 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
|
||||
Point2D finalSecondPoint = getFinalSecondPoint();
|
||||
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
// render as transparent when dragging
|
||||
int alpha = componentState == ComponentState.DRAGGING ? 0 : this.alpha;
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(boardColor);
|
||||
g2d.fillRect((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
g2d.fillRect((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
g2d.setComposite(oldComposite);
|
||||
|
||||
// Do not track any changes that follow because the whole board has been
|
||||
@@ -98,7 +103,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
drawingObserver.stopTracking();
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor);
|
||||
g2d.drawRect((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
g2d.drawRect((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
}
|
||||
|
||||
protected Point2D getFinalSecondPoint() {
|
||||
@@ -178,7 +183,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
|
||||
if (getCoordinateDisplay() == CoordinateDisplay.Both_Sides) {
|
||||
StringUtils.drawCenteredText(g2d, label,
|
||||
x, (int) Math.round(finalSecondPoint.getY() - COORDINATE_FONT_SIZE),
|
||||
x, (int) (finalSecondPoint.getY() - COORDINATE_FONT_SIZE),
|
||||
HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,24 +69,27 @@ public class BlankBoard extends AbstractBoard {
|
||||
}
|
||||
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
// if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
g2d.setColor(boardColor);
|
||||
if (getType() == Type.SQUARE)
|
||||
g2d.fillRect((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
else
|
||||
g2d.fillOval((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
g2d.setComposite(oldComposite);
|
||||
// }
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(boardColor);
|
||||
if (getType() == Type.SQUARE)
|
||||
g2d.fillRect((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
else
|
||||
g2d.fillOval((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
// Do not track any changes that follow because the whole board has been
|
||||
// tracked so far.
|
||||
drawingObserver.stopTracking();
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor);
|
||||
if (getType() == Type.SQUARE)
|
||||
g2d.drawRect((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
g2d.drawRect((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
else
|
||||
g2d.drawOval((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
g2d.drawOval((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(finalSecondPoint.getX() - firstPoint.getX()), (int)(finalSecondPoint.getY() - firstPoint.getY()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,387 +1,387 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import org.diylc.awt.StringUtils;
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.transform.ProtoBoardTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Breadboard", category = "Boards", author = "Branislav Stojkovic",
|
||||
description = "Prototyping solderless breadboard", instanceNamePrefix = "BB",
|
||||
zOrder = IDIYComponent.BOARD, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true, transformer = ProtoBoardTransformer.class)
|
||||
public class Breadboard extends AbstractProtoBoard {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color FILL_COLOR = Color.white;
|
||||
public static Color BORDER_COLOR = Color.black;
|
||||
public static Size BODY_ARC = new Size(3d, SizeUnit.mm);
|
||||
public static Size SPACING = new Size(0.1d, SizeUnit.in);
|
||||
public static Color SELECTION_COLOR = Color.red;
|
||||
public static Color HOLE_COLOR = Color.decode("#EEEEEE");
|
||||
|
||||
public static Color PLUS_COLOR = Color.red;
|
||||
public static Color MINUS_COLOR = Color.blue;
|
||||
|
||||
public static float COORDINATE_FONT_SIZE = 9f;
|
||||
public static Color COORDINATE_COLOR = Color.gray.brighter();
|
||||
|
||||
public static Size HOLE_SIZE = new Size(1.5, SizeUnit.mm);
|
||||
public static Size HOLE_ARC = new Size(1d, SizeUnit.mm);
|
||||
|
||||
protected Point2D point = new Point2D.Double(0, 0);
|
||||
|
||||
protected BreadboardSize breadboardSize;
|
||||
protected PowerStripPosition powerStripPosition;
|
||||
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
if (checkPointsClipped(g2d.getClip())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// adjust the angle
|
||||
double theta = 0;
|
||||
switch (getOrientation()) {
|
||||
case _90:
|
||||
theta = Math.PI / 2;
|
||||
break;
|
||||
case _180:
|
||||
theta = Math.PI;
|
||||
break;
|
||||
case _270:
|
||||
theta = Math.PI * 3 / 2;
|
||||
break;
|
||||
}
|
||||
if (theta != 0) {
|
||||
g2d.rotate(theta, point.getX(), point.getY());
|
||||
}
|
||||
|
||||
int bodyArc = (int) BODY_ARC.convertToPixels();
|
||||
double spacing = SPACING.convertToPixels();
|
||||
int holeCount = getBreadboardSize() == BreadboardSize.Full ? 63 : 30;
|
||||
|
||||
// draw body
|
||||
g2d.setColor(FILL_COLOR);
|
||||
int width = (int) (23 * SPACING.convertToPixels());
|
||||
int height = (int) ((holeCount + 1) * SPACING.convertToPixels());
|
||||
Shape rect = new RoundRectangle2D.Double(point.getX(), point.getY(), width, height, bodyArc, bodyArc);
|
||||
g2d.fill(rect);
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: BORDER_COLOR);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.draw(rect);
|
||||
|
||||
drawingObserver.stopTracking();
|
||||
|
||||
// draw lines
|
||||
g2d.setColor(PLUS_COLOR);
|
||||
g2d.drawLine((int) Math.round(point.getX() + spacing), (int) Math.round(point.getY() + spacing), (int) Math.round(point.getX() + spacing),
|
||||
(int) Math.round(point.getY() + holeCount * spacing));
|
||||
g2d.drawLine((int) Math.round(point.getX() + 19 * spacing), (int) Math.round(point.getY() + spacing), (int) Math.round(point.getX() + 19 * spacing),
|
||||
(int) Math.round(point.getY() + holeCount * spacing));
|
||||
g2d.setColor(MINUS_COLOR);
|
||||
g2d.drawLine((int) Math.round(point.getX() + 4 * spacing), (int) Math.round(point.getY() + spacing), (int) Math.round(point.getX() + 4 * spacing),
|
||||
(int) Math.round(point.getY() + holeCount * spacing));
|
||||
g2d.drawLine((int) Math.round(point.getX() + 22 * spacing), (int) Math.round(point.getY() + spacing), (int) Math.round(point.getX() + 22 * spacing),
|
||||
(int) Math.round(point.getY() + holeCount * spacing));
|
||||
|
||||
int holeSize = getClosestOdd(HOLE_SIZE.convertToPixels());
|
||||
int holeArc = (int) HOLE_ARC.convertToPixels();
|
||||
|
||||
g2d.setFont(LABEL_FONT.deriveFont(COORDINATE_FONT_SIZE));
|
||||
byte a = "a".getBytes()[0];
|
||||
|
||||
// draw main holes
|
||||
for (int section = 0; section <= 1; section++) {
|
||||
double offset = section * 7 * spacing;
|
||||
|
||||
for (int y = 0; y < holeCount; y++) {
|
||||
g2d.setColor(COORDINATE_COLOR);
|
||||
int coordinateX;
|
||||
if (section == 0) {
|
||||
coordinateX = (int) Math.round(point.getX() + offset + 5.5 * spacing);
|
||||
} else {
|
||||
coordinateX = (int) Math.round(point.getX() + offset + 10.5 * spacing);
|
||||
}
|
||||
StringUtils.drawCenteredText(g2d, String.valueOf(y + 1), coordinateX, (int) (point.getY() + (y + 1) * spacing),
|
||||
section == 0 ? HorizontalAlignment.RIGHT : HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||
for (int x = 0; x < 5; x++) {
|
||||
int holeX = (int) (point.getX() + offset + (x + 6) * spacing);
|
||||
int holeY = (int) (point.getY() + (y + 1) * spacing);
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(holeX - holeSize / 2, holeY - holeSize / 2, holeSize, holeSize, holeArc, holeArc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(holeX - holeSize / 2, holeY - holeSize / 2, holeSize, holeSize, holeArc, holeArc);
|
||||
|
||||
// Draw horizontal labels
|
||||
if (y == 0) {
|
||||
g2d.setColor(COORDINATE_COLOR);
|
||||
StringUtils.drawCenteredText(g2d, new String(new byte[] {(byte) (a + x + 5 * section)}), holeX, (int) Math.round(point.getY() + COORDINATE_FONT_SIZE),
|
||||
HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
StringUtils.drawCenteredText(g2d, new String(new byte[] {(byte) (a + x + 5 * section)}), holeX, (int) Math.round(point.getY()
|
||||
+ spacing * 31 - COORDINATE_FONT_SIZE / 2), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double powerOffset =
|
||||
getPowerStripPosition() == PowerStripPosition.Inline ? (getBreadboardSize() == BreadboardSize.Full ? 2d : 1d)
|
||||
: (getBreadboardSize() == BreadboardSize.Full ? 1.5d : 0.5d);
|
||||
|
||||
int psHoleCount = Math.round(holeCount / 10f) * 10;
|
||||
|
||||
// draw power strip holes
|
||||
for (int section = 0; section <= 1; section++) {
|
||||
double offset = section * 18 * spacing;
|
||||
for (int y = 0; y < psHoleCount - 1; y++) {
|
||||
for (int x = 0; x < 2; x++) {
|
||||
if ((y + 1) % 6 == 0)
|
||||
continue;
|
||||
int holeX = (int) (point.getX() + offset + (x + 2) * spacing);
|
||||
int holeY = (int) (point.getY() + (y + 1 + powerOffset) * spacing);
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(holeX - holeSize / 2, holeY - holeSize / 2, holeSize, holeSize, holeArc, holeArc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(holeX - holeSize / 2, holeY - holeSize / 2, holeSize, holeSize, holeArc, holeArc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw transparent connections just to designate connections
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.0f));
|
||||
|
||||
for (int section = 0; section <= 1; section++) {
|
||||
double offset = section * 18 * spacing;
|
||||
for (int x = 0; x < 2; x++) {
|
||||
int holeX = (int) (point.getX() + offset + (x + 2) * spacing);
|
||||
int holeY1 = (int) (point.getY() + (1 + powerOffset) * spacing);
|
||||
int holeY2 = (int) (point.getY() + (psHoleCount -1 + powerOffset) * spacing);
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(holeX - holeSize / 2, holeY1 - holeSize / 2, holeSize, holeSize + holeY2 - holeY1, holeArc, holeArc);
|
||||
}
|
||||
}
|
||||
|
||||
for (int section = 0; section <= 1; section++) {
|
||||
double offset = section * 7 * spacing;
|
||||
|
||||
for (int y = 0; y < holeCount; y++) {
|
||||
g2d.setColor(COORDINATE_COLOR);
|
||||
int coordinateX;
|
||||
if (section == 0) {
|
||||
coordinateX = (int) Math.round(point.getX() + offset + 5.5 * spacing);
|
||||
} else {
|
||||
coordinateX = (int) Math.round(point.getX() + offset + 10.5 * spacing);
|
||||
}
|
||||
StringUtils.drawCenteredText(g2d, String.valueOf(y + 1), coordinateX, (int) (point.getY() + (y + 1) * spacing),
|
||||
section == 0 ? HorizontalAlignment.RIGHT : HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||
// for (int x = 0; x < 5; x++) {
|
||||
int holeX1 = (int) Math.round(point.getX() + offset + 6 * spacing);
|
||||
int holeX2 = (int) Math.round(point.getX() + offset + 10 * spacing);
|
||||
int holeY = (int) (point.getY() + (y + 1) * spacing);
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(holeX1 - holeSize / 2, holeY - holeSize / 2, holeSize + holeX2 - holeX1, holeSize, holeArc, holeArc);
|
||||
// }
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
g2d.setComposite(oldComposite);
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
int arc = 4 / factor;
|
||||
g2d.setColor(FILL_COLOR);
|
||||
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(2 * width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(2 * width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
|
||||
g2d.setColor(MINUS_COLOR);
|
||||
g2d.drawLine(width / 2, 2 / factor, width / 2, height - 4 / factor);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Size")
|
||||
public BreadboardSize getBreadboardSize() {
|
||||
if (breadboardSize == null)
|
||||
breadboardSize = BreadboardSize.Half;
|
||||
return breadboardSize;
|
||||
}
|
||||
|
||||
public void setBreadboardSize(BreadboardSize breadboardSize) {
|
||||
this.breadboardSize = breadboardSize;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Power Strip")
|
||||
public PowerStripPosition getPowerStripPosition() {
|
||||
if (powerStripPosition == null)
|
||||
powerStripPosition = PowerStripPosition.Inline;
|
||||
return powerStripPosition;
|
||||
}
|
||||
|
||||
public void setPowerStripPosition(PowerStripPosition powerStripPosition) {
|
||||
this.powerStripPosition = powerStripPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
if (index == 0)
|
||||
return point;
|
||||
// create a synthetic second control point for clipping check and to make sure that we cannot drag the right side of the board off the screen
|
||||
double spacing = SPACING.convertToPixels();
|
||||
int holeCount = getBreadboardSize() == BreadboardSize.Full ? 63 : 30;
|
||||
// adjust the angle
|
||||
double theta = 0;
|
||||
switch (getOrientation()) {
|
||||
case _90:
|
||||
theta = Math.PI / 2;
|
||||
break;
|
||||
case _180:
|
||||
theta = Math.PI;
|
||||
break;
|
||||
case _270:
|
||||
theta = Math.PI * 3 / 2;
|
||||
break;
|
||||
}
|
||||
Point2D secondPoint = new Point2D.Double(point.getX() + 23 * spacing, point.getY() + (holeCount + 1) * spacing);
|
||||
if (theta != 0) {
|
||||
AffineTransform tx = AffineTransform.getRotateInstance(theta, point.getX(), point.getY());
|
||||
tx.transform(secondPoint, secondPoint);
|
||||
}
|
||||
return secondPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.NEVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
if (index == 0)
|
||||
this.point.setLocation(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Point2D finalSecondPoint = getControlPoint(1);
|
||||
return new Rectangle2D.Double(Math.min(point.getX(), finalSecondPoint.getX()) - 2, Math.min(point.getY(), finalSecondPoint.getY()) - 2,
|
||||
Math.abs(finalSecondPoint.getX() - point.getX()) + 4, Math.abs(finalSecondPoint.getY() - point.getY()) + 4);
|
||||
}
|
||||
|
||||
public enum BreadboardSize {
|
||||
Half, Full
|
||||
}
|
||||
|
||||
public enum PowerStripPosition {
|
||||
Inline, Offset
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import org.diylc.awt.StringUtils;
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.transform.ProtoBoardTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Breadboard", category = "Boards", author = "Branislav Stojkovic",
|
||||
description = "Prototyping solderless breadboard", instanceNamePrefix = "BB",
|
||||
zOrder = IDIYComponent.BOARD, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true, transformer = ProtoBoardTransformer.class)
|
||||
public class Breadboard extends AbstractProtoBoard {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color FILL_COLOR = Color.white;
|
||||
public static Color BORDER_COLOR = Color.black;
|
||||
public static Size BODY_ARC = new Size(3d, SizeUnit.mm);
|
||||
public static Size SPACING = new Size(0.1d, SizeUnit.in);
|
||||
public static Color SELECTION_COLOR = Color.red;
|
||||
public static Color HOLE_COLOR = Color.decode("#EEEEEE");
|
||||
|
||||
public static Color PLUS_COLOR = Color.red;
|
||||
public static Color MINUS_COLOR = Color.blue;
|
||||
|
||||
public static float COORDINATE_FONT_SIZE = 9f;
|
||||
public static Color COORDINATE_COLOR = Color.gray.brighter();
|
||||
|
||||
public static Size HOLE_SIZE = new Size(1.5, SizeUnit.mm);
|
||||
public static Size HOLE_ARC = new Size(1d, SizeUnit.mm);
|
||||
|
||||
protected Point2D point = new Point2D.Double(0, 0);
|
||||
|
||||
protected BreadboardSize breadboardSize;
|
||||
protected PowerStripPosition powerStripPosition;
|
||||
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
if (checkPointsClipped(g2d.getClip())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// adjust the angle
|
||||
double theta = 0;
|
||||
switch (getOrientation()) {
|
||||
case _90:
|
||||
theta = Math.PI / 2;
|
||||
break;
|
||||
case _180:
|
||||
theta = Math.PI;
|
||||
break;
|
||||
case _270:
|
||||
theta = Math.PI * 3 / 2;
|
||||
break;
|
||||
}
|
||||
if (theta != 0) {
|
||||
g2d.rotate(theta, point.getX(), point.getY());
|
||||
}
|
||||
|
||||
int bodyArc = (int) BODY_ARC.convertToPixels();
|
||||
double spacing = SPACING.convertToPixels();
|
||||
int holeCount = getBreadboardSize() == BreadboardSize.Full ? 63 : 30;
|
||||
|
||||
// draw body
|
||||
g2d.setColor(FILL_COLOR);
|
||||
int width = (int) (23 * SPACING.convertToPixels());
|
||||
int height = (int) ((holeCount + 1) * SPACING.convertToPixels());
|
||||
Shape rect = new RoundRectangle2D.Double(point.getX(), point.getY(), width, height, bodyArc, bodyArc);
|
||||
g2d.fill(rect);
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: BORDER_COLOR);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.draw(rect);
|
||||
|
||||
drawingObserver.stopTracking();
|
||||
|
||||
// draw lines
|
||||
g2d.setColor(PLUS_COLOR);
|
||||
g2d.drawLine((int) (point.getX() + spacing), (int) (point.getY() + spacing), (int) (point.getX() + spacing),
|
||||
(int) (point.getY() + holeCount * spacing));
|
||||
g2d.drawLine((int) (point.getX() + 19 * spacing), (int) (point.getY() + spacing), (int) (point.getX() + 19 * spacing),
|
||||
(int) (point.getY() + holeCount * spacing));
|
||||
g2d.setColor(MINUS_COLOR);
|
||||
g2d.drawLine((int) (point.getX() + 4 * spacing), (int) (point.getY() + spacing), (int) (point.getX() + 4 * spacing),
|
||||
(int) (point.getY() + holeCount * spacing));
|
||||
g2d.drawLine((int) (point.getX() + 22 * spacing), (int) (point.getY() + spacing), (int) (point.getX() + 22 * spacing),
|
||||
(int) (point.getY() + holeCount * spacing));
|
||||
|
||||
int holeSize = getClosestOdd(HOLE_SIZE.convertToPixels());
|
||||
int holeArc = (int) HOLE_ARC.convertToPixels();
|
||||
|
||||
g2d.setFont(LABEL_FONT.deriveFont(COORDINATE_FONT_SIZE));
|
||||
byte a = "a".getBytes()[0];
|
||||
|
||||
// draw main holes
|
||||
for (int section = 0; section <= 1; section++) {
|
||||
double offset = section * 7 * spacing;
|
||||
|
||||
for (int y = 0; y < holeCount; y++) {
|
||||
g2d.setColor(COORDINATE_COLOR);
|
||||
int coordinateX;
|
||||
if (section == 0) {
|
||||
coordinateX = (int) (point.getX() + offset + 5.5 * spacing);
|
||||
} else {
|
||||
coordinateX = (int) (point.getX() + offset + 10.5 * spacing);
|
||||
}
|
||||
StringUtils.drawCenteredText(g2d, String.valueOf(y + 1), coordinateX, (int) (point.getY() + (y + 1) * spacing),
|
||||
section == 0 ? HorizontalAlignment.RIGHT : HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||
for (int x = 0; x < 5; x++) {
|
||||
int holeX = (int) (point.getX() + offset + (x + 6) * spacing);
|
||||
int holeY = (int) (point.getY() + (y + 1) * spacing);
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(holeX - holeSize / 2, holeY - holeSize / 2, holeSize, holeSize, holeArc, holeArc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(holeX - holeSize / 2, holeY - holeSize / 2, holeSize, holeSize, holeArc, holeArc);
|
||||
|
||||
// Draw horizontal labels
|
||||
if (y == 0) {
|
||||
g2d.setColor(COORDINATE_COLOR);
|
||||
StringUtils.drawCenteredText(g2d, new String(new byte[] {(byte) (a + x + 5 * section)}), holeX, (int) (point.getY() + COORDINATE_FONT_SIZE),
|
||||
HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
StringUtils.drawCenteredText(g2d, new String(new byte[] {(byte) (a + x + 5 * section)}), holeX, (int) (point.getY()
|
||||
+ spacing * 31 - COORDINATE_FONT_SIZE / 2), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double powerOffset =
|
||||
getPowerStripPosition() == PowerStripPosition.Inline ? (getBreadboardSize() == BreadboardSize.Full ? 2d : 1d)
|
||||
: (getBreadboardSize() == BreadboardSize.Full ? 1.5d : 0.5d);
|
||||
|
||||
int psHoleCount = Math.round(holeCount / 10f) * 10;
|
||||
|
||||
// draw power strip holes
|
||||
for (int section = 0; section <= 1; section++) {
|
||||
double offset = section * 18 * spacing;
|
||||
for (int y = 0; y < psHoleCount - 1; y++) {
|
||||
for (int x = 0; x < 2; x++) {
|
||||
if ((y + 1) % 6 == 0)
|
||||
continue;
|
||||
int holeX = (int) (point.getX() + offset + (x + 2) * spacing);
|
||||
int holeY = (int) (point.getY() + (y + 1 + powerOffset) * spacing);
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(holeX - holeSize / 2, holeY - holeSize / 2, holeSize, holeSize, holeArc, holeArc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(holeX - holeSize / 2, holeY - holeSize / 2, holeSize, holeSize, holeArc, holeArc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw transparent connections just to designate connections
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.0f));
|
||||
|
||||
for (int section = 0; section <= 1; section++) {
|
||||
double offset = section * 18 * spacing;
|
||||
for (int x = 0; x < 2; x++) {
|
||||
int holeX = (int) (point.getX() + offset + (x + 2) * spacing);
|
||||
int holeY1 = (int) (point.getY() + (1 + powerOffset) * spacing);
|
||||
int holeY2 = (int) (point.getY() + (psHoleCount -1 + powerOffset) * spacing);
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(holeX - holeSize / 2, holeY1 - holeSize / 2, holeSize, holeSize + holeY2 - holeY1, holeArc, holeArc);
|
||||
}
|
||||
}
|
||||
|
||||
for (int section = 0; section <= 1; section++) {
|
||||
double offset = section * 7 * spacing;
|
||||
|
||||
for (int y = 0; y < holeCount; y++) {
|
||||
g2d.setColor(COORDINATE_COLOR);
|
||||
int coordinateX;
|
||||
if (section == 0) {
|
||||
coordinateX = (int) (point.getX() + offset + 5.5 * spacing);
|
||||
} else {
|
||||
coordinateX = (int) (point.getX() + offset + 10.5 * spacing);
|
||||
}
|
||||
StringUtils.drawCenteredText(g2d, String.valueOf(y + 1), coordinateX, (int) (point.getY() + (y + 1) * spacing),
|
||||
section == 0 ? HorizontalAlignment.RIGHT : HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||
// for (int x = 0; x < 5; x++) {
|
||||
int holeX1 = (int) (point.getX() + offset + 6 * spacing);
|
||||
int holeX2 = (int) (point.getX() + offset + 10 * spacing);
|
||||
int holeY = (int) (point.getY() + (y + 1) * spacing);
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(holeX1 - holeSize / 2, holeY - holeSize / 2, holeSize + holeX2 - holeX1, holeSize, holeArc, holeArc);
|
||||
// }
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
g2d.setComposite(oldComposite);
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
int arc = 4 / factor;
|
||||
g2d.setColor(FILL_COLOR);
|
||||
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(2 * width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(2 * width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
g2d.fillRoundRect(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRoundRect(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor), arc, arc);
|
||||
|
||||
g2d.setColor(MINUS_COLOR);
|
||||
g2d.drawLine(width / 2, 2 / factor, width / 2, height - 4 / factor);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Size")
|
||||
public BreadboardSize getBreadboardSize() {
|
||||
if (breadboardSize == null)
|
||||
breadboardSize = BreadboardSize.Half;
|
||||
return breadboardSize;
|
||||
}
|
||||
|
||||
public void setBreadboardSize(BreadboardSize breadboardSize) {
|
||||
this.breadboardSize = breadboardSize;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Power Strip")
|
||||
public PowerStripPosition getPowerStripPosition() {
|
||||
if (powerStripPosition == null)
|
||||
powerStripPosition = PowerStripPosition.Inline;
|
||||
return powerStripPosition;
|
||||
}
|
||||
|
||||
public void setPowerStripPosition(PowerStripPosition powerStripPosition) {
|
||||
this.powerStripPosition = powerStripPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
if (index == 0)
|
||||
return point;
|
||||
// create a synthetic second control point for clipping check and to make sure that we cannot drag the right side of the board off the screen
|
||||
double spacing = SPACING.convertToPixels();
|
||||
int holeCount = getBreadboardSize() == BreadboardSize.Full ? 63 : 30;
|
||||
// adjust the angle
|
||||
double theta = 0;
|
||||
switch (getOrientation()) {
|
||||
case _90:
|
||||
theta = Math.PI / 2;
|
||||
break;
|
||||
case _180:
|
||||
theta = Math.PI;
|
||||
break;
|
||||
case _270:
|
||||
theta = Math.PI * 3 / 2;
|
||||
break;
|
||||
}
|
||||
Point2D secondPoint = new Point2D.Double(point.getX() + 23 * spacing, point.getY() + (holeCount + 1) * spacing);
|
||||
if (theta != 0) {
|
||||
AffineTransform tx = AffineTransform.getRotateInstance(theta, point.getX(), point.getY());
|
||||
tx.transform(secondPoint, secondPoint);
|
||||
}
|
||||
return secondPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.NEVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
if (index == 0)
|
||||
this.point.setLocation(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Point2D finalSecondPoint = getControlPoint(1);
|
||||
return new Rectangle2D.Double(Math.min(point.getX(), finalSecondPoint.getX()) - 2, Math.min(point.getY(), finalSecondPoint.getY()) - 2,
|
||||
Math.abs(finalSecondPoint.getX() - point.getX()) + 4, Math.abs(finalSecondPoint.getY() - point.getY()) + 4);
|
||||
}
|
||||
|
||||
public enum BreadboardSize {
|
||||
Half, Full
|
||||
}
|
||||
|
||||
public enum PowerStripPosition {
|
||||
Inline, Offset
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -329,9 +329,9 @@ public class EurorackStripboard extends AbstractProtoBoard {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(padSize / 4));
|
||||
for (int i = 0; i < 5; i++) {
|
||||
for (Point2D[] trace : potTraces) {
|
||||
int padX1 = (int) Math.round(x0 + trace[0].getX() * spacing);
|
||||
int padX1 = (int) (x0 + trace[0].getX() * spacing);
|
||||
int padY1 = (int) (y0 + (trace[0].getY() + 8 * i) * spacing);
|
||||
int padX2 = (int) Math.round(x0 + trace[1].getX() * spacing);
|
||||
int padX2 = (int) (x0 + trace[1].getX() * spacing);
|
||||
int padY2 = (int) (y0 + (trace[1].getY() + 8 * i) * spacing);
|
||||
g2d.drawLine(padX1, padY1, padX2, padY2);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,9 @@ public class EyeletBoard extends AbstractBoard {
|
||||
}
|
||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
applyAlpha(g2d, componentState);
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
double x = firstPoint.getX();
|
||||
double y = firstPoint.getY();
|
||||
int diameter = getClosestOdd((int) EYELET_SIZE.convertToPixels());
|
||||
|
||||
+3
-1
@@ -76,7 +76,9 @@ public class MarshallPerfBoard extends AbstractBoard {
|
||||
}
|
||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
applyAlpha(g2d, componentState);
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
double x = firstPoint.getX();
|
||||
double y = firstPoint.getY();
|
||||
int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
||||
|
||||
@@ -72,7 +72,9 @@ public class PerfBoard extends AbstractBoard implements ILayeredComponent {
|
||||
}
|
||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
applyAlpha(g2d, componentState);
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
double x = firstPoint.getX();
|
||||
double y = firstPoint.getY();
|
||||
int diameter = getClosestOdd((int) PAD_SIZE.convertToPixels());
|
||||
|
||||
@@ -225,12 +225,12 @@ public class ProtoBoard extends AbstractProtoBoard {
|
||||
g2d.setColor(traceColor);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(padSize / 4));
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.drawLine((int) (point.getX() + (1 + SEGMENTS_SUM[3] + 0.5) * spacing), (int) Math.round(point.getY() + 1 * spacing),
|
||||
(int) (point.getX() + (1 + SEGMENTS_SUM[3] + 0.5) * spacing), (int) Math.round(point.getY() + 3.5 * spacing));
|
||||
g2d.drawLine((int) (point.getX() + (1 + SEGMENTS_SUM[3] + 1.5) * spacing + miniPadSize / 2), (int) Math.round(point.getY() + 1 * spacing),
|
||||
(int) (point.getX() + (1 + SEGMENTS_SUM[3] + 1.5) * spacing + miniPadSize / 2), (int) Math.round(point.getY() + 3.5 * spacing));
|
||||
g2d.drawLine((int) (point.getX() + (1 + SEGMENTS_SUM[3] + 2.5) * spacing), (int) Math.round(point.getY() + 1 * spacing),
|
||||
(int) (point.getX() + (1 + SEGMENTS_SUM[3] + 2.5) * spacing), (int) Math.round(point.getY() + 3.5 * spacing));
|
||||
g2d.drawLine((int) (point.getX() + (1 + SEGMENTS_SUM[3] + 0.5) * spacing), (int) (point.getY() + 1 * spacing),
|
||||
(int) (point.getX() + (1 + SEGMENTS_SUM[3] + 0.5) * spacing), (int) (point.getY() + 3.5 * spacing));
|
||||
g2d.drawLine((int) (point.getX() + (1 + SEGMENTS_SUM[3] + 1.5) * spacing + miniPadSize / 2), (int) (point.getY() + 1 * spacing),
|
||||
(int) (point.getX() + (1 + SEGMENTS_SUM[3] + 1.5) * spacing + miniPadSize / 2), (int) (point.getY() + 3.5 * spacing));
|
||||
g2d.drawLine((int) (point.getX() + (1 + SEGMENTS_SUM[3] + 2.5) * spacing), (int) (point.getY() + 1 * spacing),
|
||||
(int) (point.getX() + (1 + SEGMENTS_SUM[3] + 2.5) * spacing), (int) (point.getY() + 3.5 * spacing));
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
@@ -335,12 +335,12 @@ public class ProtoBoard extends AbstractProtoBoard {
|
||||
g2d.setColor(SEPARATOR_COLOR);
|
||||
g2d.draw(new Rectangle2D.Double(point.getX() + width - 5.5 * spacing, point.getY() + 2, 5 * spacing, 2 * spacing));
|
||||
|
||||
g2d.drawLine((int) Math.round(point.getX() + width - 5.5 * spacing), (int) Math.round(point.getY() + 2 * spacing) + 8,
|
||||
(int) Math.round(point.getX() + width - 5.5 * spacing), (int) Math.round(point.getY() + 3.5 * spacing));
|
||||
g2d.drawLine((int) Math.round(point.getX() + width - 4.5 * spacing), (int) Math.round(point.getY() + 2 * spacing + 8),
|
||||
(int) Math.round(point.getX() + width - 4.5 * spacing), (int) Math.round(point.getY() + 3.5 * spacing));
|
||||
g2d.drawLine((int) Math.round(point.getX() + width - 1.5 * spacing), (int) Math.round(point.getY() + 2 * spacing + 8),
|
||||
(int) Math.round(point.getX() + width - 1.5 * spacing), (int) Math.round(point.getY() + 3.5 * spacing));
|
||||
g2d.drawLine((int) (point.getX() + width - 5.5 * spacing), (int) (point.getY() + 2 * spacing) + 8,
|
||||
(int) (point.getX() + width - 5.5 * spacing), (int) (point.getY() + 3.5 * spacing));
|
||||
g2d.drawLine((int) (point.getX() + width - 4.5 * spacing), (int) (point.getY() + 2 * spacing + 8),
|
||||
(int) (point.getX() + width - 4.5 * spacing), (int) (point.getY() + 3.5 * spacing));
|
||||
g2d.drawLine((int) (point.getX() + width - 1.5 * spacing), (int) (point.getY() + 2 * spacing + 8),
|
||||
(int) (point.getX() + width - 1.5 * spacing), (int) (point.getY() + 3.5 * spacing));
|
||||
|
||||
g2d.setColor(traceColor);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(padSize / 4));
|
||||
@@ -348,8 +348,8 @@ public class ProtoBoard extends AbstractProtoBoard {
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
|
||||
// Draw two horizontal traces in the top-right section
|
||||
g2d.drawLine((int) Math.round(point.getX() + width - 4 * spacing), (int) Math.round(point.getY() + 0.5 * spacing), (int) (point.getX() + width - (2) * spacing), (int) Math.round(point.getY() + 0.5 * spacing));
|
||||
g2d.drawLine((int) Math.round(point.getX() + width - 4 * spacing), (int) Math.round(point.getY() + 1.5 * spacing), (int) (point.getX() + width - (2) * spacing), (int) Math.round(point.getY() + 1.5 * spacing));
|
||||
g2d.drawLine((int) (point.getX() + width - 4 * spacing), (int) (point.getY() + 0.5 * spacing), (int) (point.getX() + width - (2) * spacing), (int) (point.getY() + 0.5 * spacing));
|
||||
g2d.drawLine((int) (point.getX() + width - 4 * spacing), (int) (point.getY() + 1.5 * spacing), (int) (point.getX() + width - (2) * spacing), (int) (point.getY() + 1.5 * spacing));
|
||||
|
||||
// Draw top-right pads
|
||||
for (int x = 0; x < 6; x++) {
|
||||
@@ -357,7 +357,7 @@ public class ProtoBoard extends AbstractProtoBoard {
|
||||
|
||||
g2d.setColor(traceColor);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(padSize / 4));
|
||||
g2d.drawLine(padX, (int) Math.round(point.getY() + 0.5 * spacing), padX, (int) Math.round(point.getY() + 3 * spacing));
|
||||
g2d.drawLine(padX, (int) (point.getY() + 0.5 * spacing), padX, (int) (point.getY() + 3 * spacing));
|
||||
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
|
||||
@@ -433,22 +433,22 @@ public class ProtoBoard extends AbstractProtoBoard {
|
||||
g2d.setColor(textColor);
|
||||
|
||||
// Draw top labels
|
||||
StringUtils.drawCenteredText(g2d, "+5V", (int) (point.getX() + (1 + SEGMENTS_SUM[3] - 0.3) * spacing), (int) Math.round(point.getY() + 1 * spacing) + 1,
|
||||
StringUtils.drawCenteredText(g2d, "+5V", (int) (point.getX() + (1 + SEGMENTS_SUM[3] - 0.3) * spacing), (int) (point.getY() + 1 * spacing) + 1,
|
||||
HorizontalAlignment.RIGHT, VerticalAlignment.CENTER);
|
||||
StringUtils.drawCenteredText(g2d, "+12V", (int) (point.getX() + (1 + SEGMENTS_SUM[3] - 0.3) * spacing), (int) Math.round(point.getY() + 1.5 * spacing) + 1,
|
||||
StringUtils.drawCenteredText(g2d, "+12V", (int) (point.getX() + (1 + SEGMENTS_SUM[3] - 0.3) * spacing), (int) (point.getY() + 1.5 * spacing) + 1,
|
||||
HorizontalAlignment.RIGHT, VerticalAlignment.CENTER);
|
||||
StringUtils.drawCenteredText(g2d, "GND", (int) (point.getX() + (1 + SEGMENTS_SUM[3] - 0.3) * spacing), (int) Math.round(point.getY() + 2 * spacing) + 1,
|
||||
StringUtils.drawCenteredText(g2d, "GND", (int) (point.getX() + (1 + SEGMENTS_SUM[3] - 0.3) * spacing), (int) (point.getY() + 2 * spacing) + 1,
|
||||
HorizontalAlignment.RIGHT, VerticalAlignment.CENTER);
|
||||
StringUtils.drawCenteredText(g2d, "-12V", (int) (point.getX() + (1 + SEGMENTS_SUM[3] - 0.3) * spacing), (int) Math.round(point.getY() + 2.5 * spacing) + 1,
|
||||
StringUtils.drawCenteredText(g2d, "-12V", (int) (point.getX() + (1 + SEGMENTS_SUM[3] - 0.3) * spacing), (int) (point.getY() + 2.5 * spacing) + 1,
|
||||
HorizontalAlignment.RIGHT, VerticalAlignment.CENTER);
|
||||
|
||||
// Draw top-right labels
|
||||
int labelY = (int) Math.round(point.getY() + 3.8 * spacing) + 1;
|
||||
StringUtils.drawCenteredText(g2d, "+5V", (int) Math.round(point.getX() + width - 6 * spacing), labelY, HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
StringUtils.drawCenteredText(g2d, "+", (int) Math.round(point.getX() + width - 5 * spacing) - 6, labelY, HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
StringUtils.drawCenteredText(g2d, " 12V", (int) Math.round(point.getX() + width - 5 * spacing) + 2, labelY, HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
StringUtils.drawCenteredText(g2d, "GND", (int) Math.round(point.getX() + width - 3 * spacing), labelY, HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
StringUtils.drawCenteredText(g2d, "-12V", (int) Math.round(point.getX() + width - 1 * spacing), labelY, HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
int labelY = (int) (point.getY() + 3.8 * spacing) + 1;
|
||||
StringUtils.drawCenteredText(g2d, "+5V", (int) (point.getX() + width - 6 * spacing), labelY, HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
StringUtils.drawCenteredText(g2d, "+", (int) (point.getX() + width - 5 * spacing) - 6, labelY, HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
StringUtils.drawCenteredText(g2d, " 12V", (int) (point.getX() + width - 5 * spacing) + 2, labelY, HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
StringUtils.drawCenteredText(g2d, "GND", (int) (point.getX() + width - 3 * spacing), labelY, HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
StringUtils.drawCenteredText(g2d, "-12V", (int) (point.getX() + width - 1 * spacing), labelY, HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
|
||||
// Draw vertical labels
|
||||
byte A = "A".getBytes()[0];
|
||||
@@ -460,14 +460,14 @@ public class ProtoBoard extends AbstractProtoBoard {
|
||||
label = new String(new byte[] {(byte) (a + y - 26)});
|
||||
else
|
||||
label = new String(new byte[] {(byte) (A + y)});
|
||||
StringUtils.drawCenteredText(g2d, label, (int) Math.round(point.getX() + spacing * 0.35), padY, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
StringUtils.drawCenteredText(g2d, label, (int) Math.round(point.getX() + width - spacing * 0.35), padY, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
StringUtils.drawCenteredText(g2d, label, (int) (point.getX() + spacing * 0.35), padY, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
StringUtils.drawCenteredText(g2d, label, (int) (point.getX() + width - spacing * 0.35), padY, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
}
|
||||
|
||||
g2d.setColor(textColor);
|
||||
g2d.setFont(LABEL_FONT.deriveFont(COORDINATE_FONT_SIZE + 2));
|
||||
|
||||
StringUtils.drawCenteredText(g2d, "P-0+o by:\nKristian Bl�sol 2019", (int) Math.round(point.getX() + width * 0.70d), (int) (point.getY() + (yOffset + ROW_COUNT + 0.9) * spacing),
|
||||
StringUtils.drawCenteredText(g2d, "P-0+o by:\nKristian Bl�sol 2019", (int) (point.getX() + width * 0.70d), (int) (point.getY() + (yOffset + ROW_COUNT + 0.9) * spacing),
|
||||
HorizontalAlignment.LEFT, VerticalAlignment.TOP);
|
||||
|
||||
// draw central mini pads
|
||||
|
||||
@@ -150,14 +150,14 @@ public class ProtoBoard780 extends AbstractProtoBoard {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(padSize - 2f));
|
||||
|
||||
g2d.setColor(traceColor);
|
||||
int padX = (int) Math.round(point.getX() + width / 2 - 7 * spacing + i * spacing);
|
||||
int padX = (int) (point.getX() + width / 2 - 7 * spacing + i * spacing);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.drawLine(padX, (int) Math.round(point.getY() + offsetY), padX,
|
||||
(int) Math.round(point.getY() + spacing + offsetY));
|
||||
g2d.drawLine(padX, (int) (point.getY() + offsetY), padX,
|
||||
(int) (point.getY() + spacing + offsetY));
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
int padY = (int) Math.round(point.getY() + spacing * j + offsetY);
|
||||
int padY = (int) (point.getY() + spacing * j + offsetY);
|
||||
|
||||
g2d.setColor(padColor);
|
||||
|
||||
@@ -180,8 +180,8 @@ public class ProtoBoard780 extends AbstractProtoBoard {
|
||||
g2d.setColor(textColor);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int x = i == 0 ? 1 : i * 5;
|
||||
int padX = (int) Math.round(point.getX() + width / 2 - 8 * spacing + x * spacing);
|
||||
int padY = (int) Math.round(point.getY() + spacing * 2);
|
||||
int padX = (int) (point.getX() + width / 2 - 8 * spacing + x * spacing);
|
||||
int padY = (int) (point.getY() + spacing * 2);
|
||||
|
||||
// // flip the coordinates for MPJA
|
||||
// if (type == ProtoBoard780Type.MPJA) {
|
||||
@@ -201,38 +201,38 @@ public class ProtoBoard780 extends AbstractProtoBoard {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(padSize - 2f));
|
||||
|
||||
// the outer bus
|
||||
g2d.drawLine((int) Math.round(point.getX() + width / 2 - 13 * spacing),
|
||||
(int) Math.round(point.getY() - 2 * spacing + offsetY),
|
||||
(int) Math.round(point.getX() + width / 2 + 13 * spacing),
|
||||
(int) Math.round(point.getY() - 2 * spacing + offsetY));
|
||||
g2d.drawLine((int) Math.round(point.getX() + width / 2 - 13 * spacing),
|
||||
(int) Math.round(point.getY() - 2 * spacing + offsetY),
|
||||
(int) Math.round(point.getX() + width / 2 - 13 * spacing),
|
||||
g2d.drawLine((int) (point.getX() + width / 2 - 13 * spacing),
|
||||
(int) (point.getY() - 2 * spacing + offsetY),
|
||||
(int) (point.getX() + width / 2 + 13 * spacing),
|
||||
(int) (point.getY() - 2 * spacing + offsetY));
|
||||
g2d.drawLine((int) (point.getX() + width / 2 - 13 * spacing),
|
||||
(int) (point.getY() - 2 * spacing + offsetY),
|
||||
(int) (point.getX() + width / 2 - 13 * spacing),
|
||||
(int) (point.getY() + (29 + (type == ProtoBoard780Type.RS ? 2 : 0)) * spacing + offsetY));
|
||||
g2d.drawLine((int) Math.round(point.getX() + width / 2 + 13 * spacing),
|
||||
(int) Math.round(point.getY() - 2 * spacing + offsetY),
|
||||
(int) Math.round(point.getX() + width / 2 + 13 * spacing),
|
||||
g2d.drawLine((int) (point.getX() + width / 2 + 13 * spacing),
|
||||
(int) (point.getY() - 2 * spacing + offsetY),
|
||||
(int) (point.getX() + width / 2 + 13 * spacing),
|
||||
(int) (point.getY() + (29 + (type == ProtoBoard780Type.RS ? 2 : 0)) * spacing + offsetY));
|
||||
|
||||
// horizontal long traces
|
||||
g2d.drawLine((int) Math.round(point.getX() + width / 2 - 12 * spacing), (int) Math.round(point.getY() + offsetY),
|
||||
(int) Math.round(point.getX() + width / 2 + 12 * spacing), (int) Math.round(point.getY() + offsetY));
|
||||
g2d.drawLine((int) Math.round(point.getX() + width / 2 - 12 * spacing),
|
||||
(int) Math.round(point.getY() + spacing * 29 + offsetY),
|
||||
(int) Math.round(point.getX() + width / 2 + 12 * spacing),
|
||||
(int) Math.round(point.getY() + spacing * 29 + offsetY));
|
||||
g2d.drawLine((int) (point.getX() + width / 2 - 12 * spacing), (int) (point.getY() + offsetY),
|
||||
(int) (point.getX() + width / 2 + 12 * spacing), (int) (point.getY() + offsetY));
|
||||
g2d.drawLine((int) (point.getX() + width / 2 - 12 * spacing),
|
||||
(int) (point.getY() + spacing * 29 + offsetY),
|
||||
(int) (point.getX() + width / 2 + 12 * spacing),
|
||||
(int) (point.getY() + spacing * 29 + offsetY));
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int padX = (int) (point.getX() + width / 2 - 12 * spacing + (i * 5 + 1) * spacing);
|
||||
|
||||
// vertical traces
|
||||
g2d.drawLine((int) (padX - spacing), (int) Math.round(point.getY() + offsetY), (int) (padX - spacing),
|
||||
(int) Math.round(point.getY() + spacing * 28 + offsetY));
|
||||
g2d.drawLine((int) (padX + 3 * spacing), (int) Math.round(point.getY() + spacing + offsetY),
|
||||
(int) (padX + 3 * spacing), (int) Math.round(point.getY() + spacing * 29 + offsetY));
|
||||
g2d.drawLine((int) (padX - spacing), (int) (point.getY() + offsetY), (int) (padX - spacing),
|
||||
(int) (point.getY() + spacing * 28 + offsetY));
|
||||
g2d.drawLine((int) (padX + 3 * spacing), (int) (point.getY() + spacing + offsetY),
|
||||
(int) (padX + 3 * spacing), (int) (point.getY() + spacing * 29 + offsetY));
|
||||
|
||||
for (int j = 1; j < 29; j++) {
|
||||
int padY = (int) Math.round(point.getY() + spacing * j + offsetY);
|
||||
int padY = (int) (point.getY() + spacing * j + offsetY);
|
||||
|
||||
// 3-pad traces
|
||||
g2d.drawLine(padX, padY, (int) (padX + 2 * spacing), padY);
|
||||
@@ -245,14 +245,14 @@ public class ProtoBoard780 extends AbstractProtoBoard {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(padSize - 2f));
|
||||
|
||||
g2d.setColor(padColor);
|
||||
int padX = (int) Math.round(point.getX() + width / 2 - 12 * spacing + i * spacing);
|
||||
int padX = (int) (point.getX() + width / 2 - 12 * spacing + i * spacing);
|
||||
// drawingObserver.startTrackingContinuityArea(true);
|
||||
// g2d.drawLine(padX, (int) Math.round(point.getY() + offsetY), padX, (int) Math.round(point.getY() + spacing +
|
||||
// g2d.drawLine(padX, (int)(point.getY() + offsetY), padX, (int)(point.getY() + spacing +
|
||||
// offsetY));
|
||||
// drawingObserver.stopTrackingContinuityArea();
|
||||
|
||||
for (int j = 0; j < 30; j++) {
|
||||
int padY = (int) Math.round(point.getY() + spacing * j + offsetY);
|
||||
int padY = (int) (point.getY() + spacing * j + offsetY);
|
||||
|
||||
g2d.setColor(padColor);
|
||||
|
||||
@@ -277,8 +277,8 @@ public class ProtoBoard780 extends AbstractProtoBoard {
|
||||
// horizontal coordinates
|
||||
for (int i = 0; i < 6; i++) {
|
||||
int x = i == 0 ? 1 : i * 5;
|
||||
int padX = (int) Math.round(point.getX() + width / 2 - 13 * spacing + x * spacing);
|
||||
int padY = (int) Math.round(point.getY() - spacing + offsetY);
|
||||
int padX = (int) (point.getX() + width / 2 - 13 * spacing + x * spacing);
|
||||
int padY = (int) (point.getY() - spacing + offsetY);
|
||||
|
||||
String label = String.valueOf((char) ('A' + i));
|
||||
|
||||
@@ -293,7 +293,7 @@ public class ProtoBoard780 extends AbstractProtoBoard {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int y = i == 0 ? 1 : i * 5;
|
||||
|
||||
int padX = (int) Math.round(point.getX() + width / 2 - 14 * spacing);
|
||||
int padX = (int) (point.getX() + width / 2 - 14 * spacing);
|
||||
int padY = (int) (point.getY() + spacing * (y - 1) + offsetY);
|
||||
|
||||
StringUtils.drawCenteredText(g2d, Integer.toString(y), padX, padY, HorizontalAlignment.LEFT,
|
||||
@@ -302,8 +302,8 @@ public class ProtoBoard780 extends AbstractProtoBoard {
|
||||
|
||||
// model name
|
||||
g2d.setFont(LABEL_FONT.deriveFont(COORDINATE_FONT_SIZE * 1.8f));
|
||||
int x = (int) Math.round(point.getX() + width / 2);
|
||||
int y = (int) Math.round(point.getY() + length - spacing * 1.5);
|
||||
int x = (int) (point.getX() + width / 2);
|
||||
int y = (int) (point.getY() + length - spacing * 1.5);
|
||||
StringUtils.drawCenteredText(g2d,
|
||||
type == ProtoBoard780Type.RS ? "Radio Shack 276-168B" : "MPJA.COM 33304 PB", x, y,
|
||||
HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
@@ -315,32 +315,32 @@ public class ProtoBoard780 extends AbstractProtoBoard {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
|
||||
g2d.fillOval((int) Math.round(point.getX() + width / 2) - dx - mountingHoleSize / 2,
|
||||
g2d.fillOval((int) (point.getX() + width / 2) - dx - mountingHoleSize / 2,
|
||||
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
|
||||
g2d.fillOval((int) Math.round(point.getX() + width / 2) + dx - mountingHoleSize / 2,
|
||||
g2d.fillOval((int) (point.getX() + width / 2) + dx - mountingHoleSize / 2,
|
||||
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
|
||||
g2d.drawOval((int) Math.round(point.getX() + width / 2) - dx - mountingHoleSize / 2,
|
||||
g2d.drawOval((int) (point.getX() + width / 2) - dx - mountingHoleSize / 2,
|
||||
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
|
||||
g2d.drawOval((int) Math.round(point.getX() + width / 2) + dx - mountingHoleSize / 2,
|
||||
g2d.drawOval((int) (point.getX() + width / 2) + dx - mountingHoleSize / 2,
|
||||
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
|
||||
|
||||
holeY = (int) Math.round(point.getY() + length - spacing);
|
||||
holeY = (int) (point.getY() + length - spacing);
|
||||
|
||||
g2d.setColor(HOLE_COLOR);
|
||||
|
||||
g2d.fillOval((int) Math.round(point.getX() + width / 2) - dx - mountingHoleSize / 2,
|
||||
g2d.fillOval((int) (point.getX() + width / 2) - dx - mountingHoleSize / 2,
|
||||
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
|
||||
g2d.fillOval((int) Math.round(point.getX() + width / 2) + dx - mountingHoleSize / 2,
|
||||
g2d.fillOval((int) (point.getX() + width / 2) + dx - mountingHoleSize / 2,
|
||||
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
|
||||
g2d.drawOval((int) Math.round(point.getX() + width / 2) - dx - mountingHoleSize / 2,
|
||||
g2d.drawOval((int) (point.getX() + width / 2) - dx - mountingHoleSize / 2,
|
||||
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
|
||||
g2d.drawOval((int) Math.round(point.getX() + width / 2) + dx - mountingHoleSize / 2,
|
||||
g2d.drawOval((int) (point.getX() + width / 2) + dx - mountingHoleSize / 2,
|
||||
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,409 +1,412 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.transform.TagStripTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IContinuity;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Theme;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Tag Strip", author = "Branislav Stojkovic", category = "Boards",
|
||||
instanceNamePrefix = "TS", description = "Row of terminals for point-to-point construction",
|
||||
zOrder = IDIYComponent.BOARD, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = TagStripTransformer.class)
|
||||
public class TagStrip extends AbstractTransparentComponent<String> implements IContinuity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color BOARD_COLOR = PHENOLIC_DARK_COLOR;
|
||||
public static Color TERMINAL_COLOR = Color.lightGray;
|
||||
public static Color TERMINAL_BORDER_COLOR = TERMINAL_COLOR.darker();
|
||||
public static int EDGE_RADIUS = 2;
|
||||
public static Size MOUNTING_HOLE_SIZE = new Size(0.07d, SizeUnit.in);
|
||||
public static Size MOUNTING_HOLE_DISTANCE = new Size(0.25d, SizeUnit.in);
|
||||
public static Size TERMINAL_THICKNESS = new Size(0.04d, SizeUnit.in);
|
||||
|
||||
private String value = "";
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
private int terminalCount = 7;
|
||||
private static Size BOARD_THICKNESS = new Size(0.05d, SizeUnit.in);
|
||||
private Size terminalSpacing = new Size(0.375d, SizeUnit.in);
|
||||
private Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0)};
|
||||
private Color boardColor = BOARD_COLOR;
|
||||
|
||||
private TagStripMount mount = TagStripMount.Central;
|
||||
|
||||
transient private Area[] body;
|
||||
|
||||
public TagStrip() {
|
||||
super();
|
||||
updateControlPoints();
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Orientation getOrientation() {
|
||||
return orientation;
|
||||
}
|
||||
|
||||
public void setOrientation(Orientation orientation) {
|
||||
this.orientation = orientation;
|
||||
updateControlPoints();
|
||||
// Reset body shape.
|
||||
body = null;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Terminals")
|
||||
public int getTerminalCount() {
|
||||
return terminalCount;
|
||||
}
|
||||
|
||||
public void setTerminalCount(int terminalCount) {
|
||||
this.terminalCount = terminalCount;
|
||||
updateControlPoints();
|
||||
// Reset body shape;
|
||||
body = null;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Terminal Spacing", validatorClass = PositiveNonZeroMeasureValidator.class)
|
||||
public Size getTerminalSpacing() {
|
||||
return terminalSpacing;
|
||||
}
|
||||
|
||||
public void setTerminalSpacing(Size pinSpacing) {
|
||||
this.terminalSpacing = pinSpacing;
|
||||
updateControlPoints();
|
||||
// Reset body shape;
|
||||
body = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
return controlPoints[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.NEVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
controlPoints[index].setLocation(point);
|
||||
body = null;
|
||||
}
|
||||
|
||||
private void updateControlPoints() {
|
||||
Point2D firstPoint = controlPoints[0];
|
||||
controlPoints = new Point2D[getTerminalCount()];
|
||||
controlPoints[0] = firstPoint;
|
||||
int pinSpacing = (int) this.terminalSpacing.convertToPixels();
|
||||
// Update control points.
|
||||
int dx1;
|
||||
int dy1;
|
||||
for (int i = 0; i < getTerminalCount(); i++) {
|
||||
switch (orientation) {
|
||||
case DEFAULT:
|
||||
dx1 = 0;
|
||||
dy1 = i * pinSpacing;
|
||||
break;
|
||||
case _90:
|
||||
dx1 = -i * pinSpacing;
|
||||
dy1 = 0;
|
||||
break;
|
||||
case _180:
|
||||
dx1 = 0;
|
||||
dy1 = -i * pinSpacing;
|
||||
break;
|
||||
case _270:
|
||||
dx1 = i * pinSpacing;
|
||||
dy1 = 0;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||
}
|
||||
controlPoints[i] = new Point2D.Double(firstPoint.getX() + dx1, firstPoint.getY() + dy1);
|
||||
}
|
||||
}
|
||||
|
||||
public Area[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Area[1 + getTerminalCount()];
|
||||
double x = controlPoints[0].getX();
|
||||
double y = controlPoints[0].getY();
|
||||
int width;
|
||||
int height;
|
||||
int terminalSpacing = (int) getTerminalSpacing().convertToPixels();
|
||||
int boardThickness = getClosestOdd(BOARD_THICKNESS.convertToPixels());
|
||||
int boardLength = (int) ((getTerminalCount() - 0.5) * terminalSpacing + 2 * boardThickness);
|
||||
int holeSize = getClosestOdd(MOUNTING_HOLE_SIZE.convertToPixels());
|
||||
int terminalThickness = (int) TERMINAL_THICKNESS.convertToPixels();
|
||||
int terminalSize = terminalSpacing / 2;
|
||||
int holeDistance = terminalSize / 2 + terminalThickness / 2 + 1;
|
||||
int terminalWidth;
|
||||
int terminalHeight;
|
||||
int holeDx;
|
||||
int holeDy;
|
||||
switch (orientation) {
|
||||
case DEFAULT:
|
||||
width = boardThickness;
|
||||
height = boardLength;
|
||||
terminalWidth = terminalThickness;
|
||||
terminalHeight = terminalSize;
|
||||
x -= boardThickness + terminalThickness / 2;
|
||||
y -= terminalSize / 2 + boardThickness;
|
||||
holeDx = holeDistance;
|
||||
holeDy = 0;
|
||||
break;
|
||||
case _90:
|
||||
width = boardLength;
|
||||
height = boardThickness;
|
||||
terminalWidth = terminalSize;
|
||||
terminalHeight = terminalThickness;
|
||||
x += boardThickness - boardLength + terminalSize / 2;
|
||||
y -= boardThickness + terminalThickness / 2;
|
||||
holeDx = 0;
|
||||
holeDy = holeDistance;
|
||||
break;
|
||||
case _180:
|
||||
width = boardThickness;
|
||||
height = boardLength;
|
||||
terminalWidth = terminalThickness;
|
||||
terminalHeight = terminalSize;
|
||||
x += terminalThickness / 2;
|
||||
y += boardThickness - boardLength + terminalSize / 2;
|
||||
holeDx = -holeDistance;
|
||||
holeDy = 0;
|
||||
break;
|
||||
case _270:
|
||||
width = boardLength;
|
||||
height = boardThickness;
|
||||
terminalWidth = terminalSize;
|
||||
terminalHeight = terminalThickness;
|
||||
x -= terminalSize / 2 + boardThickness;
|
||||
y -= -terminalThickness / 2;
|
||||
holeDx = 0;
|
||||
holeDy = -holeDistance;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||
}
|
||||
Area bodyArea = new Area(new Rectangle2D.Double(x, y, width, height));
|
||||
body[0] = bodyArea;
|
||||
|
||||
for (int i = 0; i < getTerminalCount(); i++) {
|
||||
Point2D p1 = getControlPoint(i);
|
||||
Area terminal =
|
||||
new Area(new Rectangle2D.Double(p1.getX() - terminalWidth/ 2, p1.getY() - terminalHeight / 2, terminalWidth, terminalHeight));
|
||||
|
||||
body[1 + i] = terminal;
|
||||
|
||||
if ((getMount() == TagStripMount.Central && i == getTerminalCount() / 2) || (getMount() == TagStripMount.Outside && (i == 0 || i == getTerminalCount() - 1))) {
|
||||
Area mount = new Area(new Rectangle2D.Double(p1.getX() + holeDx - terminalSize / 2, p1.getY() + holeDy - terminalSize / 2, terminalSize, terminalSize));
|
||||
mount.subtract(new Area(new Ellipse2D.Double(p1.getX() + holeDx - holeSize / 2, p1.getY() + holeDy - holeSize / 2, holeSize, holeSize)));
|
||||
body[1 + i].add(mount);
|
||||
}
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
if (checkPointsClipped(g2d.getClip())) {
|
||||
return;
|
||||
}
|
||||
Area[] area = getBody();
|
||||
Area mainArea = area[0];
|
||||
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBoardColor());
|
||||
g2d.fill(mainArea);
|
||||
|
||||
Color finalBorderColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: getBoardColor().darker();
|
||||
}
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
g2d.draw(mainArea);
|
||||
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : TERMINAL_COLOR);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
for (int i = 1; i < body.length; i++)
|
||||
g2d.fill(body[i]);
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
|
||||
Color finalTerminalBorderColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalTerminalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
} else {
|
||||
finalTerminalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: TERMINAL_BORDER_COLOR;
|
||||
}
|
||||
|
||||
g2d.setColor(finalTerminalBorderColor);
|
||||
for (int i = 1; i < body.length; i++)
|
||||
g2d.draw(body[i]);
|
||||
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||
g2d.setColor(BOARD_COLOR);
|
||||
int thickness = 2 * width / 32;
|
||||
g2d.fillRect(0, height / 2 - thickness / 2, width, thickness);
|
||||
g2d.setColor(TERMINAL_COLOR.darker());
|
||||
int terminalWidth = 7 * width / 32;
|
||||
g2d.fillRect(2, height / 2 + thickness / 2, terminalWidth, thickness);
|
||||
g2d.fillRect((int) (2 + terminalWidth * 1.5), height / 2 + thickness / 2, terminalWidth, thickness);
|
||||
g2d.fillRect((int) (2 + terminalWidth * 3), height / 2 + thickness / 2, terminalWidth, thickness);
|
||||
g2d.setColor(TERMINAL_COLOR);
|
||||
g2d.fillRect((int) (2 + terminalWidth * 1.5), height / 2 + thickness / 2 + 1, terminalWidth, terminalWidth);
|
||||
g2d.setColor(Color.white);
|
||||
g2d.fillOval((int) (2 + terminalWidth * 1.75), height / 2 + thickness / 2 + 1 + terminalWidth / 2, terminalWidth / 2, terminalWidth / 2);
|
||||
// int radius = 6 * width / 32;
|
||||
// int holeSize = 3 * width / 32;
|
||||
// g2d.setColor(BOARD_COLOR);
|
||||
// g2d.fillRect(width / 4, 1, width / 2, height - 4);
|
||||
// g2d.setColor(BORDER_COLOR);
|
||||
// g2d.drawRect(width / 4, 1, width / 2, height - 4);
|
||||
// int terminalSize = getClosestOdd(height / 5);
|
||||
// Area terminal =
|
||||
// new Area(new RoundRectangle2D.Double(2 * width / 32, height / 5, width - 4 * width / 32, terminalSize, radius,
|
||||
// radius));
|
||||
// terminal.subtract(new Area(new Ellipse2D.Double(2 * width / 32 + holeSize, height * 3 / 10 - holeSize / 2, holeSize, holeSize)));
|
||||
// terminal.subtract(new Area(new Ellipse2D.Double(width - 2 * width / 32 - holeSize * 2, height * 3 / 10 - holeSize / 2, holeSize, holeSize)));
|
||||
//
|
||||
// g2d.setColor(TERMINAL_COLOR);
|
||||
// g2d.fill(terminal);
|
||||
// g2d.setColor(TERMINAL_BORDER_COLOR);
|
||||
// g2d.draw(terminal);
|
||||
// g2d.translate(0, height * 2 / 5);
|
||||
// g2d.setColor(TERMINAL_COLOR);
|
||||
// g2d.fill(terminal);
|
||||
// g2d.setColor(TERMINAL_BORDER_COLOR);
|
||||
// g2d.draw(terminal);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Board")
|
||||
public Color getBoardColor() {
|
||||
if (boardColor == null) {
|
||||
boardColor = BOARD_COLOR;
|
||||
}
|
||||
return boardColor;
|
||||
}
|
||||
|
||||
public void setBoardColor(Color bodyColor) {
|
||||
this.boardColor = bodyColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return "TerminalStrip" + index;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Mounting Lugs")
|
||||
public TagStripMount getMount() {
|
||||
return mount;
|
||||
}
|
||||
|
||||
public void setMount(TagStripMount mount) {
|
||||
this.mount = mount;
|
||||
updateControlPoints();
|
||||
// Reset body shape;
|
||||
body = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean arePointsConnected(int index1, int index2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public enum TagStripMount {
|
||||
Central, Outside;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.transform.TagStripTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IContinuity;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Theme;
|
||||
import org.diylc.core.VisibilityPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Tag Strip", author = "Branislav Stojkovic", category = "Boards",
|
||||
instanceNamePrefix = "TS", description = "Row of terminals for point-to-point construction",
|
||||
zOrder = IDIYComponent.BOARD, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = TagStripTransformer.class)
|
||||
public class TagStrip extends AbstractTransparentComponent<String> implements IContinuity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color BOARD_COLOR = PHENOLIC_DARK_COLOR;
|
||||
public static Color TERMINAL_COLOR = Color.lightGray;
|
||||
public static Color TERMINAL_BORDER_COLOR = TERMINAL_COLOR.darker();
|
||||
public static int EDGE_RADIUS = 2;
|
||||
public static Size MOUNTING_HOLE_SIZE = new Size(0.07d, SizeUnit.in);
|
||||
public static Size MOUNTING_HOLE_DISTANCE = new Size(0.25d, SizeUnit.in);
|
||||
public static Size TERMINAL_THICKNESS = new Size(0.04d, SizeUnit.in);
|
||||
|
||||
private String value = "";
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
private int terminalCount = 7;
|
||||
private static Size BOARD_THICKNESS = new Size(0.05d, SizeUnit.in);
|
||||
private Size terminalSpacing = new Size(0.375d, SizeUnit.in);
|
||||
private Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0)};
|
||||
private Color boardColor = BOARD_COLOR;
|
||||
|
||||
private TagStripMount mount = TagStripMount.Central;
|
||||
|
||||
transient private Area[] body;
|
||||
|
||||
public TagStrip() {
|
||||
super();
|
||||
updateControlPoints();
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Orientation getOrientation() {
|
||||
return orientation;
|
||||
}
|
||||
|
||||
public void setOrientation(Orientation orientation) {
|
||||
this.orientation = orientation;
|
||||
updateControlPoints();
|
||||
// Reset body shape.
|
||||
body = null;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Terminals")
|
||||
public int getTerminalCount() {
|
||||
return terminalCount;
|
||||
}
|
||||
|
||||
public void setTerminalCount(int terminalCount) {
|
||||
this.terminalCount = terminalCount;
|
||||
updateControlPoints();
|
||||
// Reset body shape;
|
||||
body = null;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Terminal Spacing", validatorClass = PositiveNonZeroMeasureValidator.class)
|
||||
public Size getTerminalSpacing() {
|
||||
return terminalSpacing;
|
||||
}
|
||||
|
||||
public void setTerminalSpacing(Size pinSpacing) {
|
||||
this.terminalSpacing = pinSpacing;
|
||||
updateControlPoints();
|
||||
// Reset body shape;
|
||||
body = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2D getControlPoint(int index) {
|
||||
return controlPoints[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||
return VisibilityPolicy.NEVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point2D point, int index) {
|
||||
controlPoints[index].setLocation(point);
|
||||
body = null;
|
||||
}
|
||||
|
||||
private void updateControlPoints() {
|
||||
Point2D firstPoint = controlPoints[0];
|
||||
controlPoints = new Point2D[getTerminalCount()];
|
||||
controlPoints[0] = firstPoint;
|
||||
int pinSpacing = (int) this.terminalSpacing.convertToPixels();
|
||||
// Update control points.
|
||||
int dx1;
|
||||
int dy1;
|
||||
for (int i = 0; i < getTerminalCount(); i++) {
|
||||
switch (orientation) {
|
||||
case DEFAULT:
|
||||
dx1 = 0;
|
||||
dy1 = i * pinSpacing;
|
||||
break;
|
||||
case _90:
|
||||
dx1 = -i * pinSpacing;
|
||||
dy1 = 0;
|
||||
break;
|
||||
case _180:
|
||||
dx1 = 0;
|
||||
dy1 = -i * pinSpacing;
|
||||
break;
|
||||
case _270:
|
||||
dx1 = i * pinSpacing;
|
||||
dy1 = 0;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||
}
|
||||
controlPoints[i] = new Point2D.Double(firstPoint.getX() + dx1, firstPoint.getY() + dy1);
|
||||
}
|
||||
}
|
||||
|
||||
public Area[] getBody() {
|
||||
if (body == null) {
|
||||
body = new Area[1 + getTerminalCount()];
|
||||
double x = controlPoints[0].getX();
|
||||
double y = controlPoints[0].getY();
|
||||
int width;
|
||||
int height;
|
||||
int terminalSpacing = (int) getTerminalSpacing().convertToPixels();
|
||||
int boardThickness = getClosestOdd(BOARD_THICKNESS.convertToPixels());
|
||||
int boardLength = (int) ((getTerminalCount() - 0.5) * terminalSpacing + 2 * boardThickness);
|
||||
int holeSize = getClosestOdd(MOUNTING_HOLE_SIZE.convertToPixels());
|
||||
int terminalThickness = (int) TERMINAL_THICKNESS.convertToPixels();
|
||||
int terminalSize = terminalSpacing / 2;
|
||||
int holeDistance = terminalSize / 2 + terminalThickness / 2 + 1;
|
||||
int terminalWidth;
|
||||
int terminalHeight;
|
||||
int holeDx;
|
||||
int holeDy;
|
||||
switch (orientation) {
|
||||
case DEFAULT:
|
||||
width = boardThickness;
|
||||
height = boardLength;
|
||||
terminalWidth = terminalThickness;
|
||||
terminalHeight = terminalSize;
|
||||
x -= boardThickness + terminalThickness / 2;
|
||||
y -= terminalSize / 2 + boardThickness;
|
||||
holeDx = holeDistance;
|
||||
holeDy = 0;
|
||||
break;
|
||||
case _90:
|
||||
width = boardLength;
|
||||
height = boardThickness;
|
||||
terminalWidth = terminalSize;
|
||||
terminalHeight = terminalThickness;
|
||||
x += boardThickness - boardLength + terminalSize / 2;
|
||||
y -= boardThickness + terminalThickness / 2;
|
||||
holeDx = 0;
|
||||
holeDy = holeDistance;
|
||||
break;
|
||||
case _180:
|
||||
width = boardThickness;
|
||||
height = boardLength;
|
||||
terminalWidth = terminalThickness;
|
||||
terminalHeight = terminalSize;
|
||||
x += terminalThickness / 2;
|
||||
y += boardThickness - boardLength + terminalSize / 2;
|
||||
holeDx = -holeDistance;
|
||||
holeDy = 0;
|
||||
break;
|
||||
case _270:
|
||||
width = boardLength;
|
||||
height = boardThickness;
|
||||
terminalWidth = terminalSize;
|
||||
terminalHeight = terminalThickness;
|
||||
x -= terminalSize / 2 + boardThickness;
|
||||
y -= -terminalThickness / 2;
|
||||
holeDx = 0;
|
||||
holeDy = -holeDistance;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unexpected orientation: " + orientation);
|
||||
}
|
||||
Area bodyArea = new Area(new Rectangle2D.Double(x, y, width, height));
|
||||
body[0] = bodyArea;
|
||||
|
||||
for (int i = 0; i < getTerminalCount(); i++) {
|
||||
Point2D p1 = getControlPoint(i);
|
||||
Area terminal =
|
||||
new Area(new Rectangle2D.Double(p1.getX() - terminalWidth/ 2, p1.getY() - terminalHeight / 2, terminalWidth, terminalHeight));
|
||||
|
||||
body[1 + i] = terminal;
|
||||
|
||||
if ((getMount() == TagStripMount.Central && i == getTerminalCount() / 2) || (getMount() == TagStripMount.Outside && (i == 0 || i == getTerminalCount() - 1))) {
|
||||
Area mount = new Area(new Rectangle2D.Double(p1.getX() + holeDx - terminalSize / 2, p1.getY() + holeDy - terminalSize / 2, terminalSize, terminalSize));
|
||||
mount.subtract(new Area(new Ellipse2D.Double(p1.getX() + holeDx - holeSize / 2, p1.getY() + holeDy - holeSize / 2, holeSize, holeSize)));
|
||||
body[1 + i].add(mount);
|
||||
}
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
if (checkPointsClipped(g2d.getClip())) {
|
||||
return;
|
||||
}
|
||||
Area[] area = getBody();
|
||||
Area mainArea = area[0];
|
||||
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBoardColor());
|
||||
g2d.fill(mainArea);
|
||||
|
||||
Color finalBorderColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
} else {
|
||||
finalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: getBoardColor().darker();
|
||||
}
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
|
||||
g2d.setColor(finalBorderColor);
|
||||
g2d.draw(mainArea);
|
||||
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : TERMINAL_COLOR);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
for (int i = 1; i < body.length; i++)
|
||||
g2d.fill(body[i]);
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
|
||||
Color finalTerminalBorderColor;
|
||||
if (outlineMode) {
|
||||
Theme theme =
|
||||
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
|
||||
finalTerminalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: theme.getOutlineColor();
|
||||
} else {
|
||||
finalTerminalBorderColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: TERMINAL_BORDER_COLOR;
|
||||
}
|
||||
|
||||
g2d.setColor(finalTerminalBorderColor);
|
||||
for (int i = 1; i < body.length; i++)
|
||||
g2d.draw(body[i]);
|
||||
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||
g2d.setColor(BOARD_COLOR);
|
||||
int thickness = 2 * width / 32;
|
||||
g2d.fillRect(0, height / 2 - thickness / 2, width, thickness);
|
||||
g2d.setColor(TERMINAL_COLOR.darker());
|
||||
int terminalWidth = 7 * width / 32;
|
||||
g2d.fillRect(2, height / 2 + thickness / 2, terminalWidth, thickness);
|
||||
g2d.fillRect((int) (2 + terminalWidth * 1.5), height / 2 + thickness / 2, terminalWidth, thickness);
|
||||
g2d.fillRect((int) (2 + terminalWidth * 3), height / 2 + thickness / 2, terminalWidth, thickness);
|
||||
g2d.setColor(TERMINAL_COLOR);
|
||||
g2d.fillRect((int) (2 + terminalWidth * 1.5), height / 2 + thickness / 2 + 1, terminalWidth, terminalWidth);
|
||||
g2d.setColor(Color.white);
|
||||
g2d.fillOval((int) (2 + terminalWidth * 1.75), height / 2 + thickness / 2 + 1 + terminalWidth / 2, terminalWidth / 2, terminalWidth / 2);
|
||||
// int radius = 6 * width / 32;
|
||||
// int holeSize = 3 * width / 32;
|
||||
// g2d.setColor(BOARD_COLOR);
|
||||
// g2d.fillRect(width / 4, 1, width / 2, height - 4);
|
||||
// g2d.setColor(BORDER_COLOR);
|
||||
// g2d.drawRect(width / 4, 1, width / 2, height - 4);
|
||||
// int terminalSize = getClosestOdd(height / 5);
|
||||
// Area terminal =
|
||||
// new Area(new RoundRectangle2D.Double(2 * width / 32, height / 5, width - 4 * width / 32, terminalSize, radius,
|
||||
// radius));
|
||||
// terminal.subtract(new Area(new Ellipse2D.Double(2 * width / 32 + holeSize, height * 3 / 10 - holeSize / 2, holeSize, holeSize)));
|
||||
// terminal.subtract(new Area(new Ellipse2D.Double(width - 2 * width / 32 - holeSize * 2, height * 3 / 10 - holeSize / 2, holeSize, holeSize)));
|
||||
//
|
||||
// g2d.setColor(TERMINAL_COLOR);
|
||||
// g2d.fill(terminal);
|
||||
// g2d.setColor(TERMINAL_BORDER_COLOR);
|
||||
// g2d.draw(terminal);
|
||||
// g2d.translate(0, height * 2 / 5);
|
||||
// g2d.setColor(TERMINAL_COLOR);
|
||||
// g2d.fill(terminal);
|
||||
// g2d.setColor(TERMINAL_BORDER_COLOR);
|
||||
// g2d.draw(terminal);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Board")
|
||||
public Color getBoardColor() {
|
||||
if (boardColor == null) {
|
||||
boardColor = BOARD_COLOR;
|
||||
}
|
||||
return boardColor;
|
||||
}
|
||||
|
||||
public void setBoardColor(Color bodyColor) {
|
||||
this.boardColor = bodyColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return "TerminalStrip" + index;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Mounting Lugs")
|
||||
public TagStripMount getMount() {
|
||||
return mount;
|
||||
}
|
||||
|
||||
public void setMount(TagStripMount mount) {
|
||||
this.mount = mount;
|
||||
updateControlPoints();
|
||||
// Reset body shape;
|
||||
body = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean arePointsConnected(int index1, int index2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public enum TagStripMount {
|
||||
Central, Outside;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,10 @@ public class TerminalStrip extends AbstractTransparentComponent<String> implemen
|
||||
Area[] body = getBody();
|
||||
Area mainArea = getBody()[0];
|
||||
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBoardColor());
|
||||
g2d.fill(mainArea);
|
||||
|
||||
|
||||
@@ -1,210 +1,213 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.components.transform.VeroBoardTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.ILayeredComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "TriPad Board", category = "Boards", author = "Hauke Juhls", zOrder = IDIYComponent.BOARD,
|
||||
instanceNamePrefix = "Board",
|
||||
description = "Perforated FR4 board with copper strips connecting 3 holes in a row (aka TriPad Board)",
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = VeroBoardTransformer.class, enableCache = true)
|
||||
public class TriPadBoard extends AbstractVeroBoard implements ILayeredComponent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected int stripSpan = 3; // determines how many holes are covered by a
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
Point2D finalSecondPoint = getFinalSecondPoint();
|
||||
|
||||
Shape clip = g2d.getClip();
|
||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.getX(), finalSecondPoint.getY())
|
||||
&& !clip.contains(finalSecondPoint.getX(), firstPoint.getY())) {
|
||||
return;
|
||||
}
|
||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
double x = firstPoint.getX();
|
||||
double y = firstPoint.getY();
|
||||
int stripSize = getClosestOdd((int) STRIP_SIZE.convertToPixels());
|
||||
int holeSize = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
||||
double spacing = this.spacing.convertToPixels();
|
||||
|
||||
if (orientation == OrientationHV.HORIZONTAL) {
|
||||
while (y < finalSecondPoint.getY() - spacing - stripSize / 2) {
|
||||
x = firstPoint.getX();
|
||||
y += spacing;
|
||||
|
||||
while (x + spacing < finalSecondPoint.getX()) {
|
||||
|
||||
double remainingSpace = finalSecondPoint.getX() - x;
|
||||
double spacesToDraw = stripSpan;
|
||||
|
||||
if (remainingSpace < (stripSize + (stripSpan * spacing))) {
|
||||
spacesToDraw = (remainingSpace - stripSize) / spacing;
|
||||
}
|
||||
|
||||
g2d.setColor(stripColor);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.fillRect((int)(x + spacing - stripSize / 2), (int)(y - stripSize / 2), (int)(spacing * (spacesToDraw - 1) + stripSize),
|
||||
stripSize);
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
g2d.setColor(stripColor.darker());
|
||||
|
||||
g2d.drawRect((int)(x + spacing - stripSize / 2), (int)(y - stripSize / 2), (int)(spacing * (spacesToDraw - 1) + stripSize),
|
||||
stripSize);
|
||||
|
||||
x += spacing * spacesToDraw;
|
||||
}
|
||||
|
||||
// draw holes
|
||||
x = firstPoint.getX();
|
||||
|
||||
while (x < finalSecondPoint.getX() - spacing - holeSize) {
|
||||
x += spacing;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (x < finalSecondPoint.getX() - spacing) {
|
||||
x += spacing;
|
||||
y = firstPoint.getY();
|
||||
|
||||
while (y + spacing < finalSecondPoint.getY()) {
|
||||
|
||||
double remainingSpace = finalSecondPoint.getY() - y;
|
||||
double spacesToDraw = stripSpan;
|
||||
|
||||
if (remainingSpace < (stripSize + (stripSpan * spacing))) {
|
||||
spacesToDraw = (remainingSpace - stripSize) / spacing;
|
||||
}
|
||||
|
||||
g2d.setColor(stripColor);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.fillRect((int)(x - stripSize / 2), (int)(y + spacing - stripSize / 2), stripSize, (int)(spacing * (spacesToDraw - 1)
|
||||
+ stripSize));
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawRect((int)(x - stripSize / 2), (int)(y + spacing - stripSize / 2), stripSize, (int)(spacing * (spacesToDraw - 1)
|
||||
+ stripSize));
|
||||
|
||||
y += spacing * spacesToDraw;
|
||||
}
|
||||
|
||||
// draw holes
|
||||
y = firstPoint.getY();
|
||||
|
||||
while (y < finalSecondPoint.getY() - spacing - holeSize) {
|
||||
y += spacing;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
|
||||
super.drawCoordinates(g2d, spacing, project);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.setColor(PHENOLIC_COLOR);
|
||||
g2d.fillRect(0, 0, width, height);
|
||||
|
||||
final int horizontalSpacing = width / 5;
|
||||
final int horizontalIndent = horizontalSpacing / 2;
|
||||
|
||||
final int verticalSpacing = height / 5;
|
||||
final int verticalIndent = verticalSpacing / 2;
|
||||
|
||||
for (int row = 0; row < 5; row++) {
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillRect(0, row * verticalSpacing + 2, horizontalIndent / 2 + horizontalSpacing, verticalSpacing - 1);
|
||||
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillRect(horizontalSpacing + 2, row * verticalSpacing + 2, horizontalSpacing * 3 - 1, verticalSpacing - 1);
|
||||
|
||||
g2d.fillRect(horizontalSpacing * 4 + 2, row * verticalSpacing + 2, horizontalIndent / 2 + horizontalSpacing,
|
||||
verticalSpacing - 1);
|
||||
}
|
||||
|
||||
// draw dots
|
||||
for (int row = 0; row < 5; row++) {
|
||||
int y = (verticalSpacing * row) + verticalIndent;
|
||||
for (int col = 0; col < 5; col++) {
|
||||
int x = (horizontalSpacing * col) + horizontalIndent;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval(x, y, 2, 2);
|
||||
g2d.setColor(COPPER_COLOR.darker());
|
||||
g2d.drawOval(x, y, 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Holes Per Strip")
|
||||
public int getStripSpan() {
|
||||
return stripSpan;
|
||||
}
|
||||
|
||||
public void setStripSpan(int stripSpan) {
|
||||
if (stripSpan < 1) {
|
||||
this.stripSpan = 1;
|
||||
} else {
|
||||
this.stripSpan = stripSpan;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayerId() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.components.transform.VeroBoardTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.ILayeredComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "TriPad Board", category = "Boards", author = "Hauke Juhls", zOrder = IDIYComponent.BOARD,
|
||||
instanceNamePrefix = "Board",
|
||||
description = "Perforated FR4 board with copper strips connecting 3 holes in a row (aka TriPad Board)",
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = VeroBoardTransformer.class, enableCache = true)
|
||||
public class TriPadBoard extends AbstractVeroBoard implements ILayeredComponent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected int stripSpan = 3; // determines how many holes are covered by a
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
Point2D finalSecondPoint = getFinalSecondPoint();
|
||||
|
||||
Shape clip = g2d.getClip();
|
||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.getX(), finalSecondPoint.getY())
|
||||
&& !clip.contains(finalSecondPoint.getX(), firstPoint.getY())) {
|
||||
return;
|
||||
}
|
||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
double x = firstPoint.getX();
|
||||
double y = firstPoint.getY();
|
||||
int stripSize = getClosestOdd((int) STRIP_SIZE.convertToPixels());
|
||||
int holeSize = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
||||
double spacing = this.spacing.convertToPixels();
|
||||
|
||||
if (orientation == OrientationHV.HORIZONTAL) {
|
||||
while (y < finalSecondPoint.getY() - spacing - stripSize / 2) {
|
||||
x = firstPoint.getX();
|
||||
y += spacing;
|
||||
|
||||
while (x + spacing < finalSecondPoint.getX()) {
|
||||
|
||||
double remainingSpace = finalSecondPoint.getX() - x;
|
||||
double spacesToDraw = stripSpan;
|
||||
|
||||
if (remainingSpace < (stripSize + (stripSpan * spacing))) {
|
||||
spacesToDraw = (remainingSpace - stripSize) / spacing;
|
||||
}
|
||||
|
||||
g2d.setColor(stripColor);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.fillRect((int)(x + spacing - stripSize / 2), (int)(y - stripSize / 2), (int)(spacing * (spacesToDraw - 1) + stripSize),
|
||||
stripSize);
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
g2d.setColor(stripColor.darker());
|
||||
|
||||
g2d.drawRect((int)(x + spacing - stripSize / 2), (int)(y - stripSize / 2), (int)(spacing * (spacesToDraw - 1) + stripSize),
|
||||
stripSize);
|
||||
|
||||
x += spacing * spacesToDraw;
|
||||
}
|
||||
|
||||
// draw holes
|
||||
x = firstPoint.getX();
|
||||
|
||||
while (x < finalSecondPoint.getX() - spacing - holeSize) {
|
||||
x += spacing;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (x < finalSecondPoint.getX() - spacing) {
|
||||
x += spacing;
|
||||
y = firstPoint.getY();
|
||||
|
||||
while (y + spacing < finalSecondPoint.getY()) {
|
||||
|
||||
double remainingSpace = finalSecondPoint.getY() - y;
|
||||
double spacesToDraw = stripSpan;
|
||||
|
||||
if (remainingSpace < (stripSize + (stripSpan * spacing))) {
|
||||
spacesToDraw = (remainingSpace - stripSize) / spacing;
|
||||
}
|
||||
|
||||
g2d.setColor(stripColor);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.fillRect((int)(x - stripSize / 2), (int)(y + spacing - stripSize / 2), stripSize, (int)(spacing * (spacesToDraw - 1)
|
||||
+ stripSize));
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawRect((int)(x - stripSize / 2), (int)(y + spacing - stripSize / 2), stripSize, (int)(spacing * (spacesToDraw - 1)
|
||||
+ stripSize));
|
||||
|
||||
y += spacing * spacesToDraw;
|
||||
}
|
||||
|
||||
// draw holes
|
||||
y = firstPoint.getY();
|
||||
|
||||
while (y < finalSecondPoint.getY() - spacing - holeSize) {
|
||||
y += spacing;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
|
||||
super.drawCoordinates(g2d, spacing, project);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.setColor(PHENOLIC_COLOR);
|
||||
g2d.fillRect(0, 0, width, height);
|
||||
|
||||
final int horizontalSpacing = width / 5;
|
||||
final int horizontalIndent = horizontalSpacing / 2;
|
||||
|
||||
final int verticalSpacing = height / 5;
|
||||
final int verticalIndent = verticalSpacing / 2;
|
||||
|
||||
for (int row = 0; row < 5; row++) {
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillRect(0, row * verticalSpacing + 2, horizontalIndent / 2 + horizontalSpacing, verticalSpacing - 1);
|
||||
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillRect(horizontalSpacing + 2, row * verticalSpacing + 2, horizontalSpacing * 3 - 1, verticalSpacing - 1);
|
||||
|
||||
g2d.fillRect(horizontalSpacing * 4 + 2, row * verticalSpacing + 2, horizontalIndent / 2 + horizontalSpacing,
|
||||
verticalSpacing - 1);
|
||||
}
|
||||
|
||||
// draw dots
|
||||
for (int row = 0; row < 5; row++) {
|
||||
int y = (verticalSpacing * row) + verticalIndent;
|
||||
for (int col = 0; col < 5; col++) {
|
||||
int x = (horizontalSpacing * col) + horizontalIndent;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval(x, y, 2, 2);
|
||||
g2d.setColor(COPPER_COLOR.darker());
|
||||
g2d.drawOval(x, y, 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Holes Per Strip")
|
||||
public int getStripSpan() {
|
||||
return stripSpan;
|
||||
}
|
||||
|
||||
public void setStripSpan(int stripSpan) {
|
||||
if (stripSpan < 1) {
|
||||
this.stripSpan = 1;
|
||||
} else {
|
||||
this.stripSpan = stripSpan;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayerId() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,152 +1,155 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.components.transform.VeroBoardTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.ILayeredComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Vero Board", category = "Boards", author = "Branislav Stojkovic",
|
||||
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board",
|
||||
description = "Perforated FR4 board with copper strips connecting all holes in a row",
|
||||
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME,
|
||||
transformer = VeroBoardTransformer.class, enableCache = true)
|
||||
public class VeroBoard extends AbstractVeroBoard implements ILayeredComponent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
Point2D finalSecondPoint = getFinalSecondPoint();
|
||||
|
||||
Shape clip = g2d.getClip();
|
||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.getX(), finalSecondPoint.getY())
|
||||
&& !clip.contains(finalSecondPoint.getX(), firstPoint.getY())) {
|
||||
return;
|
||||
}
|
||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
double x = firstPoint.getX();
|
||||
double y = firstPoint.getY();
|
||||
int stripSize = getClosestOdd((int) STRIP_SIZE.convertToPixels());
|
||||
int holeSize = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
||||
int spacing = (int) this.spacing.convertToPixels();
|
||||
|
||||
if (orientation == OrientationHV.HORIZONTAL) {
|
||||
while (y < finalSecondPoint.getY() - spacing - stripSize / 2) {
|
||||
x = firstPoint.getX();
|
||||
y += spacing;
|
||||
g2d.setColor(stripColor);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.fillRect((int)(x + spacing / 2), (int)(y - stripSize / 2), (int) Math.round(finalSecondPoint.getX() - spacing - x), stripSize);
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawRect((int)(x + spacing / 2), (int)(y - stripSize / 2), (int) Math.round(finalSecondPoint.getX() - spacing - x), stripSize);
|
||||
while (x < finalSecondPoint.getX() - spacing - holeSize) {
|
||||
x += spacing;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (x < finalSecondPoint.getX() - spacing) {
|
||||
x += spacing;
|
||||
y = firstPoint.getY();
|
||||
g2d.setColor(stripColor);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.fillRect((int)(x - stripSize / 2), (int)(y + spacing / 2), stripSize, (int) Math.round(finalSecondPoint.getY() - spacing - y));
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawRect((int)(x - stripSize / 2), (int)(y + spacing / 2), stripSize, (int) Math.round(finalSecondPoint.getY() - spacing - y));
|
||||
while (y < finalSecondPoint.getY() - spacing - holeSize) {
|
||||
y += spacing;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
super.drawCoordinates(g2d, spacing, project);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayerId() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
g2d.setColor(PHENOLIC_COLOR);
|
||||
g2d.fillRect(0, 2 / factor, width - 1, height - 4 / factor);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRect(0, 2 / factor, width - 1, height - 4 / factor);
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillRect(1 / factor, width / 4, width - 2 / factor, width / 2);
|
||||
g2d.setColor(COPPER_COLOR.darker());
|
||||
g2d.drawRect(1 / factor, width / 4, width - 2 / factor, width / 2);
|
||||
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillRect(1 / factor, 2 / factor, width - 2 / factor, 3 / factor);
|
||||
g2d.fillRect(1 / factor, height - 5 / factor, width - 2 / factor, 3 / factor);
|
||||
g2d.setColor(COPPER_COLOR.darker());
|
||||
g2d.drawRect(1 / factor, 2 / factor, width - 2 / factor, 3 / factor);
|
||||
g2d.drawRect(1 / factor, height - 5 / factor, width - 2 / factor, 3 / factor);
|
||||
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval(width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor));
|
||||
g2d.fillOval(2 * width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor));
|
||||
g2d.setColor(COPPER_COLOR.darker());
|
||||
g2d.drawOval(width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor));
|
||||
g2d.drawOval(2 * width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor));
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.components.transform.VeroBoardTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.ILayeredComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Vero Board", category = "Boards", author = "Branislav Stojkovic",
|
||||
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board",
|
||||
description = "Perforated FR4 board with copper strips connecting all holes in a row",
|
||||
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME,
|
||||
transformer = VeroBoardTransformer.class, enableCache = true)
|
||||
public class VeroBoard extends AbstractVeroBoard implements ILayeredComponent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
Point2D finalSecondPoint = getFinalSecondPoint();
|
||||
|
||||
Shape clip = g2d.getClip();
|
||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.getX(), finalSecondPoint.getY())
|
||||
&& !clip.contains(finalSecondPoint.getX(), firstPoint.getY())) {
|
||||
return;
|
||||
}
|
||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
double x = firstPoint.getX();
|
||||
double y = firstPoint.getY();
|
||||
int stripSize = getClosestOdd((int) STRIP_SIZE.convertToPixels());
|
||||
int holeSize = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
||||
int spacing = (int) this.spacing.convertToPixels();
|
||||
|
||||
if (orientation == OrientationHV.HORIZONTAL) {
|
||||
while (y < finalSecondPoint.getY() - spacing - stripSize / 2) {
|
||||
x = firstPoint.getX();
|
||||
y += spacing;
|
||||
g2d.setColor(stripColor);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.fillRect((int)(x + spacing / 2), (int)(y - stripSize / 2), (int)(finalSecondPoint.getX() - spacing - x), stripSize);
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawRect((int)(x + spacing / 2), (int)(y - stripSize / 2), (int)(finalSecondPoint.getX() - spacing - x), stripSize);
|
||||
while (x < finalSecondPoint.getX() - spacing - holeSize) {
|
||||
x += spacing;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (x < finalSecondPoint.getX() - spacing) {
|
||||
x += spacing;
|
||||
y = firstPoint.getY();
|
||||
g2d.setColor(stripColor);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.fillRect((int)(x - stripSize / 2), (int)(y + spacing / 2), stripSize, (int)(finalSecondPoint.getY() - spacing - y));
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawRect((int)(x - stripSize / 2), (int)(y + spacing / 2), stripSize, (int)(finalSecondPoint.getY() - spacing - y));
|
||||
while (y < finalSecondPoint.getY() - spacing - holeSize) {
|
||||
y += spacing;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
g2d.setColor(stripColor.darker());
|
||||
g2d.drawOval((int)(x - holeSize / 2), (int)(y - holeSize / 2), holeSize, holeSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
super.drawCoordinates(g2d, spacing, project);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayerId() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
g2d.setColor(PHENOLIC_COLOR);
|
||||
g2d.fillRect(0, 2 / factor, width - 1, height - 4 / factor);
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRect(0, 2 / factor, width - 1, height - 4 / factor);
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillRect(1 / factor, width / 4, width - 2 / factor, width / 2);
|
||||
g2d.setColor(COPPER_COLOR.darker());
|
||||
g2d.drawRect(1 / factor, width / 4, width - 2 / factor, width / 2);
|
||||
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillRect(1 / factor, 2 / factor, width - 2 / factor, 3 / factor);
|
||||
g2d.fillRect(1 / factor, height - 5 / factor, width - 2 / factor, 3 / factor);
|
||||
g2d.setColor(COPPER_COLOR.darker());
|
||||
g2d.drawRect(1 / factor, 2 / factor, width - 2 / factor, 3 / factor);
|
||||
g2d.drawRect(1 / factor, height - 5 / factor, width - 2 / factor, 3 / factor);
|
||||
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval(width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor));
|
||||
g2d.fillOval(2 * width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor));
|
||||
g2d.setColor(COPPER_COLOR.darker());
|
||||
g2d.drawOval(width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor));
|
||||
g2d.drawOval(2 * width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
|
||||
getClosestOdd(5.0 / factor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,108 +1,97 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.chassis;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.shapes.AbstractShape;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Chassis Panel", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "CP", description = "One side of a chassis, with or withouth rounded edges",
|
||||
zOrder = IDIYComponent.CHASSIS, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
||||
transformer = SimpleComponentTransformer.class)
|
||||
public class ChassisPanel extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected Size edgeRadius = new Size(0d, SizeUnit.mm);
|
||||
|
||||
public ChassisPanel() {
|
||||
this.color = LIGHT_METAL_COLOR;
|
||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||
int radius = (int) edgeRadius.convertToPixels();
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
g2d.setColor(color);
|
||||
if (radius == 0) {
|
||||
g2d.fillRect((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()),
|
||||
(int) (secondPoint.getX() - firstPoint.getX()),
|
||||
(int) (secondPoint.getY() - firstPoint.getY()));
|
||||
} else {
|
||||
g2d.fillRoundRect((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()),
|
||||
(int) (secondPoint.getX() - firstPoint.getX()),
|
||||
(int) (secondPoint.getY() - firstPoint.getY()), radius, radius);
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
drawingObserver.stopTracking();
|
||||
}
|
||||
// Do not track any changes that follow because the whole rect has been
|
||||
// tracked so far.
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor);
|
||||
if (radius == 0) {
|
||||
g2d.drawRect((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()),
|
||||
(int) (secondPoint.getX() - firstPoint.getX()),
|
||||
(int) (secondPoint.getY() - firstPoint.getY()));
|
||||
} else {
|
||||
g2d.drawRoundRect((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()),
|
||||
(int) (secondPoint.getX() - firstPoint.getX()),
|
||||
(int) (secondPoint.getY() - firstPoint.getY()), radius, radius);
|
||||
}
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Radius")
|
||||
public Size getEdgeRadius() {
|
||||
return edgeRadius;
|
||||
}
|
||||
|
||||
public void setEdgeRadius(Size edgeRadius) {
|
||||
this.edgeRadius = edgeRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
g2d.setColor(LIGHT_METAL_COLOR);
|
||||
g2d.fillRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||
g2d.drawRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.chassis;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.shapes.AbstractShape;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Chassis Panel", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "CP", description = "One side of a chassis, with or withouth rounded edges",
|
||||
zOrder = IDIYComponent.CHASSIS, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
||||
transformer = SimpleComponentTransformer.class)
|
||||
public class ChassisPanel extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected Size edgeRadius = new Size(0d, SizeUnit.mm);
|
||||
|
||||
public ChassisPanel() {
|
||||
this.color = LIGHT_METAL_COLOR;
|
||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||
int radius = (int) edgeRadius.convertToPixels();
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(color);
|
||||
g2d.fillRoundRect((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(secondPoint.getX() - firstPoint.getX()), (int)(secondPoint.getY() - firstPoint.getY()), radius,
|
||||
radius);
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
// Do not track any changes that follow because the whole rect has been
|
||||
// tracked so far.
|
||||
drawingObserver.stopTracking();
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor);
|
||||
g2d.drawRoundRect((int)(firstPoint.getX()), (int)(firstPoint.getY()), (int)(secondPoint.getX() - firstPoint.getX()), (int)(secondPoint.getY() - firstPoint.getY()), radius,
|
||||
radius);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Radius")
|
||||
public Size getEdgeRadius() {
|
||||
return edgeRadius;
|
||||
}
|
||||
|
||||
public void setEdgeRadius(Size edgeRadius) {
|
||||
this.edgeRadius = edgeRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
g2d.setColor(LIGHT_METAL_COLOR);
|
||||
g2d.fillRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||
g2d.drawRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,36 +125,6 @@ public class DialScale extends AbstractComponent<String> {
|
||||
g2d.setStroke(tickStroke);
|
||||
g2d.drawLine((int)x, (int)y, (int)x1, (int)y1);
|
||||
break;
|
||||
case Ticks_Mixed:
|
||||
case Ticks_0_5_5_11: {
|
||||
boolean majorTick = (i == 2 || i == 5 || i == 8);
|
||||
double tickLen = majorTick ? marker : marker * 0.8;
|
||||
x1 = x0 + Math.cos(alpha) * (r - tickLen);
|
||||
y1 = y0 + Math.sin(alpha) * (r - tickLen);
|
||||
g2d.setStroke(tickStroke);
|
||||
g2d.drawLine((int)x, (int)y, (int)x1, (int)y1);
|
||||
if (type == DialScaleType.Ticks_0_5_5_11) {
|
||||
String label = null;
|
||||
VerticalAlignment vAlign = VerticalAlignment.CENTER;
|
||||
if (i == 0) {
|
||||
label = "0";
|
||||
vAlign = VerticalAlignment.TOP;
|
||||
} else if (i == 5) {
|
||||
label = "5.5";
|
||||
vAlign = VerticalAlignment.BOTTOM;
|
||||
} else if (i == 10) {
|
||||
label = "11";
|
||||
vAlign = VerticalAlignment.TOP;
|
||||
}
|
||||
if (label != null) {
|
||||
double labelPad = marker * 0.95;
|
||||
double lx = x0 + Math.cos(alpha) * (r + labelPad);
|
||||
double ly = y0 + Math.sin(alpha) * (r + labelPad);
|
||||
StringUtils.drawCenteredText(g2d, label, lx, ly, HorizontalAlignment.CENTER, vAlign);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Numeric_Even:
|
||||
if (i % 2 == 0) {
|
||||
StringUtils.drawCenteredText(g2d, Integer.toString(i), x, y, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
@@ -303,7 +273,7 @@ public class DialScale extends AbstractComponent<String> {
|
||||
}
|
||||
|
||||
public enum DialScaleType {
|
||||
Ticks_Mixed("Ticks"), Ticks("Ticks (Uniform)"), Ticks_0_5_5_11("Ticks + Numeric (0/5.5/11)"), Dots("Dots (Uniform)"), Dots_Gradual("Dots (Gradual)"), Numeric_0_10("Numeric (0-10)"), Numeric_1_11("Numeric (1-11)"),
|
||||
Ticks("Ticks"), Dots("Dots (Uniform)"), Dots_Gradual("Dots (Gradual)"), Numeric_0_10("Numeric (0-10)"), Numeric_1_11("Numeric (1-11)"),
|
||||
Numeric_1_10("Numeric (1-10)"), Numeric_1_12("Numeric (1-12)"), Numeric_Even("Numeric (Even, No Ticks)"), Numeric_Even_Ticks("Numeric (Even, With Ticks)");
|
||||
|
||||
private String label;
|
||||
|
||||
+75
-72
@@ -1,72 +1,75 @@
|
||||
/*
|
||||
*
|
||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
*
|
||||
* This file is part of DIYLC.
|
||||
*
|
||||
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.diylc.components.chassis;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.shapes.AbstractShape;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
|
||||
@ComponentDescriptor(name = "Elliptical Cutout", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "ELC", description = "Elliptical chassis cutout", zOrder = IDIYComponent.CHASSIS + 0.1,
|
||||
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
|
||||
public class EllipticalCutout extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public EllipticalCutout() {
|
||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
g2d.setColor(color);
|
||||
g2d.fillOval((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()), (int)(secondPoint.getX() - firstPoint.getX()), (int)(secondPoint.getY() - firstPoint.getY()));
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
// Do not track any changes that follow because the whole oval has been
|
||||
// tracked so far.
|
||||
drawingObserver.stopTracking();
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor);
|
||||
g2d.drawOval((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()), (int)(secondPoint.getX() - firstPoint.getX()), (int)(secondPoint.getY() - firstPoint.getY()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
g2d.setColor(COLOR);
|
||||
g2d.fillOval(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||
g2d.drawOval(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
*
|
||||
* This file is part of DIYLC.
|
||||
*
|
||||
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.diylc.components.chassis;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.shapes.AbstractShape;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
|
||||
@ComponentDescriptor(name = "Elliptical Cutout", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "ELC", description = "Elliptical chassis cutout", zOrder = IDIYComponent.CHASSIS + 0.1,
|
||||
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
|
||||
public class EllipticalCutout extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public EllipticalCutout() {
|
||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(color);
|
||||
g2d.fillOval((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(secondPoint.getX() - firstPoint.getX()), (int)(secondPoint.getY() - firstPoint.getY()));
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
// Do not track any changes that follow because the whole oval has been
|
||||
// tracked so far.
|
||||
drawingObserver.stopTracking();
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor);
|
||||
g2d.drawOval((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(secondPoint.getX() - firstPoint.getX()), (int)(secondPoint.getY() - firstPoint.getY()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
g2d.setColor(COLOR);
|
||||
g2d.fillOval(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||
g2d.drawOval(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||
}
|
||||
}
|
||||
|
||||
+126
-123
@@ -1,123 +1,126 @@
|
||||
/*
|
||||
*
|
||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
*
|
||||
* This file is part of DIYLC.
|
||||
*
|
||||
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.diylc.components.chassis;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.shapes.AbstractShape;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
@ComponentDescriptor(name = "Polygonal Cutout", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "POLYC", description = "Polygonal chassis cutout", zOrder = IDIYComponent.CHASSIS + 0.1,
|
||||
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
|
||||
public class PolygonalCutout extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected PointCount pointCount = PointCount._4;
|
||||
|
||||
public PolygonalCutout() {
|
||||
super();
|
||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||
this.controlPoints =
|
||||
new Point2D[] {new Point2D.Double(0, 0),
|
||||
new Point2D.Double(0, (int) DEFAULT_HEIGHT.convertToPixels()),
|
||||
new Point2D.Double((int) DEFAULT_WIDTH.convertToPixels(), (int) DEFAULT_HEIGHT.convertToPixels()),
|
||||
new Point2D.Double((int) DEFAULT_WIDTH.convertToPixels(), 0)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||
g2d.setColor(color);
|
||||
int[] xPoints = new int[controlPoints.length];
|
||||
int[] yPoints = new int[controlPoints.length];
|
||||
for (int i = 0; i < controlPoints.length; i++) {
|
||||
xPoints[i] = (int)controlPoints[i].getX();
|
||||
yPoints[i] = (int)controlPoints[i].getY();
|
||||
}
|
||||
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
g2d.fillPolygon(xPoints, yPoints, controlPoints.length);
|
||||
g2d.setComposite(oldComposite);
|
||||
|
||||
// Do not track any changes that follow because the whole board has been
|
||||
// tracked so far.
|
||||
drawingObserver.stopTracking();
|
||||
Color lineColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor;
|
||||
g2d.setColor(lineColor);
|
||||
g2d.drawPolygon(xPoints, yPoints, controlPoints.length);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Edges")
|
||||
public PointCount getPointCount() {
|
||||
return pointCount;
|
||||
}
|
||||
|
||||
public void setPointCount(PointCount pointCount) {
|
||||
if (this.pointCount == pointCount)
|
||||
return;
|
||||
int oldPointCount = Integer.parseInt(this.pointCount.toString());
|
||||
int newPointCount = Integer.parseInt(pointCount.toString());
|
||||
this.controlPoints = Arrays.copyOf(this.controlPoints, newPointCount);
|
||||
if (oldPointCount < newPointCount) {
|
||||
this.controlPoints[newPointCount - 1] = this.controlPoints[oldPointCount - 1];
|
||||
for (int i = oldPointCount - 1; i < newPointCount - 1; i++) {
|
||||
this.controlPoints[i] =
|
||||
new Point2D.Double((this.controlPoints[i - 1].getX() + this.controlPoints[newPointCount - 1].getX()) / 2,
|
||||
(this.controlPoints[i - 1].getY() + this.controlPoints[newPointCount - 1].getY()) / 2);
|
||||
}
|
||||
}
|
||||
this.pointCount = pointCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
g2d.setColor(COLOR);
|
||||
int[] x = {2 / factor, width - 2 / factor, width - 4 / factor, 3 / factor};
|
||||
int[] y = {4 / factor, 2 / factor, height - 5 / factor, height - 2 / factor};
|
||||
g2d.fillPolygon(x, y, 4);
|
||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||
g2d.drawPolygon(x, y, 4);
|
||||
}
|
||||
|
||||
public enum PointCount {
|
||||
_3, _4, _5, _6, _7, _8;
|
||||
|
||||
public String toString() {
|
||||
return name().substring(1);
|
||||
};
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
*
|
||||
* This file is part of DIYLC.
|
||||
*
|
||||
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.diylc.components.chassis;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.shapes.AbstractShape;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
@ComponentDescriptor(name = "Polygonal Cutout", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "POLYC", description = "Polygonal chassis cutout", zOrder = IDIYComponent.CHASSIS + 0.1,
|
||||
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
|
||||
public class PolygonalCutout extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected PointCount pointCount = PointCount._4;
|
||||
|
||||
public PolygonalCutout() {
|
||||
super();
|
||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||
this.controlPoints =
|
||||
new Point2D[] {new Point2D.Double(0, 0),
|
||||
new Point2D.Double(0, (int) DEFAULT_HEIGHT.convertToPixels()),
|
||||
new Point2D.Double((int) DEFAULT_WIDTH.convertToPixels(), (int) DEFAULT_HEIGHT.convertToPixels()),
|
||||
new Point2D.Double((int) DEFAULT_WIDTH.convertToPixels(), 0)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||
g2d.setColor(color);
|
||||
int[] xPoints = new int[controlPoints.length];
|
||||
int[] yPoints = new int[controlPoints.length];
|
||||
for (int i = 0; i < controlPoints.length; i++) {
|
||||
xPoints[i] = (int)controlPoints[i].getX();
|
||||
yPoints[i] = (int)controlPoints[i].getY();
|
||||
}
|
||||
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (this.alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(3, 1.0F * this.alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.fillPolygon(xPoints, yPoints, controlPoints.length);
|
||||
g2d.setComposite(oldComposite);
|
||||
|
||||
// Do not track any changes that follow because the whole board has been
|
||||
// tracked so far.
|
||||
drawingObserver.stopTracking();
|
||||
Color lineColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor;
|
||||
g2d.setColor(lineColor);
|
||||
g2d.drawPolygon(xPoints, yPoints, controlPoints.length);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Edges")
|
||||
public PointCount getPointCount() {
|
||||
return pointCount;
|
||||
}
|
||||
|
||||
public void setPointCount(PointCount pointCount) {
|
||||
if (this.pointCount == pointCount)
|
||||
return;
|
||||
int oldPointCount = Integer.parseInt(this.pointCount.toString());
|
||||
int newPointCount = Integer.parseInt(pointCount.toString());
|
||||
this.controlPoints = Arrays.copyOf(this.controlPoints, newPointCount);
|
||||
if (oldPointCount < newPointCount) {
|
||||
this.controlPoints[newPointCount - 1] = this.controlPoints[oldPointCount - 1];
|
||||
for (int i = oldPointCount - 1; i < newPointCount - 1; i++) {
|
||||
this.controlPoints[i] =
|
||||
new Point2D.Double((this.controlPoints[i - 1].getX() + this.controlPoints[newPointCount - 1].getX()) / 2,
|
||||
(this.controlPoints[i - 1].getY() + this.controlPoints[newPointCount - 1].getY()) / 2);
|
||||
}
|
||||
}
|
||||
this.pointCount = pointCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
g2d.setColor(COLOR);
|
||||
int[] x = {2 / factor, width - 2 / factor, width - 4 / factor, 3 / factor};
|
||||
int[] y = {4 / factor, 2 / factor, height - 5 / factor, height - 2 / factor};
|
||||
g2d.fillPolygon(x, y, 4);
|
||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||
g2d.drawPolygon(x, y, 4);
|
||||
}
|
||||
|
||||
public enum PointCount {
|
||||
_3, _4, _5, _6, _7, _8;
|
||||
|
||||
public String toString() {
|
||||
return name().substring(1);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+92
-89
@@ -1,89 +1,92 @@
|
||||
/*
|
||||
*
|
||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
*
|
||||
* This file is part of DIYLC.
|
||||
*
|
||||
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.diylc.components.chassis;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.shapes.AbstractShape;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Rectangular Cutout", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "RECTC", description = "Rectangular chassis cutout, with or without rounded edges",
|
||||
zOrder = IDIYComponent.CHASSIS + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||
transformer = SimpleComponentTransformer.class)
|
||||
public class RectangularCutout extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected Size edgeRadius = new Size(0d, SizeUnit.mm);
|
||||
|
||||
public RectangularCutout() {
|
||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||
int radius = (int) edgeRadius.convertToPixels();
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = applyAlpha(g2d, componentState);
|
||||
g2d.setColor(color);
|
||||
g2d.fillRoundRect((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()), (int)(secondPoint.getX() - firstPoint.getX()), (int)(secondPoint.getY() - firstPoint.getY()), radius,
|
||||
radius);
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
// Do not track any changes that follow because the whole rect has been
|
||||
// tracked so far.
|
||||
drawingObserver.stopTracking();
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor);
|
||||
g2d.drawRoundRect((int) Math.round(firstPoint.getX()), (int) Math.round(firstPoint.getY()), (int)(secondPoint.getX() - firstPoint.getX()), (int)(secondPoint.getY() - firstPoint.getY()), radius,
|
||||
radius);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Radius")
|
||||
public Size getEdgeRadius() {
|
||||
return edgeRadius;
|
||||
}
|
||||
|
||||
public void setEdgeRadius(Size edgeRadius) {
|
||||
this.edgeRadius = edgeRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
g2d.setColor(COLOR);
|
||||
g2d.fillRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||
g2d.drawRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
*
|
||||
* This file is part of DIYLC.
|
||||
*
|
||||
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.diylc.components.chassis;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.components.shapes.AbstractShape;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Rectangular Cutout", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "RECTC", description = "Rectangular chassis cutout, with or without rounded edges",
|
||||
zOrder = IDIYComponent.CHASSIS + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||
transformer = SimpleComponentTransformer.class)
|
||||
public class RectangularCutout extends AbstractShape {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected Size edgeRadius = new Size(0d, SizeUnit.mm);
|
||||
|
||||
public RectangularCutout() {
|
||||
this.borderColor = LIGHT_METAL_COLOR.darker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((int) borderThickness.convertToPixels()));
|
||||
int radius = (int) edgeRadius.convertToPixels();
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
if (alpha < MAX_ALPHA) {
|
||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||
}
|
||||
g2d.setColor(color);
|
||||
g2d.fillRoundRect((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(secondPoint.getX() - firstPoint.getX()), (int)(secondPoint.getY() - firstPoint.getY()), radius,
|
||||
radius);
|
||||
g2d.setComposite(oldComposite);
|
||||
}
|
||||
// Do not track any changes that follow because the whole rect has been
|
||||
// tracked so far.
|
||||
drawingObserver.stopTracking();
|
||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: borderColor);
|
||||
g2d.drawRoundRect((int)firstPoint.getX(), (int)firstPoint.getY(), (int)(secondPoint.getX() - firstPoint.getX()), (int)(secondPoint.getY() - firstPoint.getY()), radius,
|
||||
radius);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Radius")
|
||||
public Size getEdgeRadius() {
|
||||
return edgeRadius;
|
||||
}
|
||||
|
||||
public void setEdgeRadius(Size edgeRadius) {
|
||||
this.edgeRadius = edgeRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int factor = 32 / width;
|
||||
g2d.setColor(COLOR);
|
||||
g2d.fillRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
||||
g2d.setColor(LIGHT_METAL_COLOR.darker());
|
||||
g2d.drawRect(2 / factor, 4 / factor, width - 4 / factor, height - 8 / factor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.bancika.gerberwriter.GerberFunctions;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.PCBLayer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.components.LineEndingStyle;
|
||||
import org.diylc.components.transform.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.CreationMethod;
|
||||
@@ -59,7 +58,6 @@ public class CopperTrace extends AbstractLeadedComponent<Void> implements ILayer
|
||||
|
||||
private Size thickness = THICKNESS;
|
||||
private PCBLayer layer = PCBLayer._1;
|
||||
private LineEndingStyle endingStyle = LineEndingStyle.Round;
|
||||
|
||||
public CopperTrace() {
|
||||
super();
|
||||
@@ -204,19 +202,6 @@ public class CopperTrace extends AbstractLeadedComponent<Void> implements ILayer
|
||||
return false;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Ending Style")
|
||||
@Override
|
||||
public LineEndingStyle getEndingStyle() {
|
||||
if (endingStyle == null) {
|
||||
endingStyle = LineEndingStyle.Round;
|
||||
}
|
||||
return endingStyle;
|
||||
}
|
||||
|
||||
public void setEndingStyle(LineEndingStyle endingStyle) {
|
||||
this.endingStyle = endingStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<GerberRenderMode> getGerberRenderModes() {
|
||||
return EnumSet.of(GerberRenderMode.Normal);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user