Compare commits

..

260 Commits

Author SHA1 Message Date
bancika ca492354ab 2011-01-30 18:47:44 +00:00
bancika 629fb5fff7 2011-01-30 18:46:38 +00:00
bancika bc154608f4 allow property edit validation 2011-01-30 17:21:42 +00:00
bancika a8cc661d09 better error handling when drawing 2011-01-30 14:10:38 +00:00
bancika 0b10f0bfe3 V1 file importer can recognize hookup wire and transistors 2011-01-30 12:02:29 +00:00
bancika f435571aae added keyboard shortcuts to some menu options 2011-01-30 11:43:54 +00:00
bancika 6bb248032f added square pad 2011-01-30 11:32:55 +00:00
bancika 1b04023a93 added axial electrolytic 2011-01-29 22:38:46 +00:00
bancika a32c8c4c8d added axial electrolytic 2011-01-29 22:35:09 +00:00
bancika 4a89159c80 reset component selection when switching tabs 2011-01-29 22:00:33 +00:00
bancika e5113e110e reset component selection when switching tabs 2011-01-29 22:00:01 +00:00
bancika c2051fcea2 improved electrolytic cap and resistor 2011-01-29 21:56:43 +00:00
bancika a42592410e improved electrolytic cap and resistor 2011-01-29 21:55:51 +00:00
bancika 22185a2d14 Potentiometer misdraw at 180 degrees 2011-01-29 18:31:25 +00:00
bancika ac6aaf4e06 added LED 2011-01-29 13:47:00 +00:00
bancika 1be52c1dfa improved zooming 2011-01-29 09:49:28 +00:00
bancika 328d09123b removed sysout 2011-01-29 09:02:19 +00:00
bancika 04cd80b561 added TO220 transistor
improved status text
2011-01-29 08:59:53 +00:00
bancika 3a419ba3bc added transistor 2011-01-28 20:05:37 +00:00
bancika 971ceb7160 added template support 2011-01-28 19:21:35 +00:00
bancika e0d8990954 added template support 2011-01-28 19:19:05 +00:00
bancika a70ec95822 added template support 2011-01-28 19:13:49 +00:00
bancika 8aacf915e3 added template support 2011-01-28 18:57:21 +00:00
bancika 777d3f6deb added template support 2011-01-28 18:55:40 +00:00
bancika 7de327b9bd fixed point visibility on curved trace
added option to hide color bands on the resistor
2011-01-28 17:48:46 +00:00
bancika 11b7756a59 added resistor color codes
fixed double value parsing
2011-01-27 22:34:41 +00:00
bancika b3351ef081 version info 2011-01-27 20:17:06 +00:00
bancika b1dbf4f1d2 added action to right click menu 2011-01-27 19:52:59 +00:00
bancika 9161182924 added send to back/bring to front 2011-01-27 19:49:33 +00:00
bancika 94f769f785 added send to back/bring to front 2011-01-27 19:44:37 +00:00
bancika 6dffcd6349 added send to back/bring to front 2011-01-27 19:41:36 +00:00
bancika 6fad7a2427 fixed NPE and wrong undo/redo for ungroup 2011-01-27 19:21:34 +00:00
bancika 4ab6231590 refactored actions out
added right click menu
2011-01-27 19:16:40 +00:00
bancika 5de6caf073 fixed bug with file name when creating new file 2011-01-26 23:57:09 +00:00
bancika be7ab3412d optimize image saving/loading 2011-01-26 23:50:48 +00:00
bancika 3dd4a4c5e3 added worker thread 2011-01-26 21:49:57 +00:00
bancika fb6f973a6e added worker thread 2011-01-26 21:48:57 +00:00
bancika e8d45e1426 added image alpha 2011-01-26 21:06:51 +00:00
bancika 51c916cbb5 added image component 2011-01-26 20:09:15 +00:00
bancika a8ba97dc77 revived cut action 2011-01-26 19:45:44 +00:00
bancika 103860a42b added update file 2011-01-26 19:04:51 +00:00
bancika 126d629cdc refactored awt.transferable out of the presenter
fixed copy/paste between instances
2011-01-26 18:44:40 +00:00
bancika f28dda37a6 optimize refresh when creating new component 2011-01-25 22:48:51 +00:00
bancika 3a7fdeb792 allow curve shape control points to overlap 2011-01-25 21:38:37 +00:00
bancika 13e0cec8ad better logging 2011-01-25 19:13:07 +00:00
bancika df33d7fd6e improved IC 2011-01-24 21:28:53 +00:00
bancika 2f672bf2b4 round corners 2011-01-24 21:02:33 +00:00
bancika e84f77a7ca pulled out scripting because of locale issues 2011-01-24 20:58:18 +00:00
bancika efeaf92ccb ability to center label 2011-01-24 20:12:51 +00:00
bancika 8927b2c326 tweak control point visibility 2011-01-24 20:00:11 +00:00
bancika 3476d3a608 import text component 2011-01-24 19:49:04 +00:00
bancika 6c052403d3 import electrolytics 2011-01-24 19:40:22 +00:00
bancika 1322f48918 removed unused ode 2011-01-24 19:23:03 +00:00
bancika 62cbe4826f improved stick mechanism when more than one point is stuck 2011-01-24 19:13:09 +00:00
bancika 2aa8aed874 improved importer for v1 2011-01-24 18:54:04 +00:00
bancika 6d361283a1 Configurable wheel zoom 2011-01-24 18:21:57 +00:00
bancika b33b6b6495 show selection size on demand
removed scroll buttons in toolbox
2011-01-24 18:17:13 +00:00
bancika fb5baf9571 added transparency to pot 2011-01-23 23:54:24 +00:00
bancika 2d6927993e fixed creation bug with d&d 2011-01-23 23:47:35 +00:00
bancika 5806d17e56 added v1 conversion warnings 2011-01-23 23:25:20 +00:00
bancika fcc001cb98 reduced number of base layers 2011-01-23 23:18:45 +00:00
bancika 1de1b9d6ec refactored some swing out of the core parts 2011-01-23 22:57:52 +00:00
bancika 726f17aa7f refactor some swing references 2011-01-23 19:58:47 +00:00
bancika 72ae295a09 fixed NPE 2011-01-23 18:51:04 +00:00
bancika 0aa61ecd8a 2011-01-23 18:34:15 +00:00
bancika 4106d2dad5 added label 2011-01-23 18:23:34 +00:00
bancika f9c08ecbaa changed curve position
synchronous messages
added pot
2011-01-23 17:26:34 +00:00
bancika a422c9ad2d don't stick to locked components 2011-01-22 13:23:58 +00:00
bancika 1cede9e071 added layer locking 2011-01-22 13:20:40 +00:00
bancika 664bf91852 added layer locking
added eyelet board
2011-01-22 13:17:43 +00:00
bancika 99d85a2d1f fixed drag&drop when spacing changes 2011-01-21 23:06:48 +00:00
bancika 9fdf7c3e46 added radial electrolytic 2011-01-21 22:03:52 +00:00
bancika 2c00a7a973 improved piece of code 2011-01-21 21:17:30 +00:00
bancika 91509c2bce added plastic diode 2011-01-21 21:10:57 +00:00
bancika abe9fbbbd5 added plastic diode 2011-01-21 21:09:17 +00:00
bancika 5e886ed90c turn off auto gc 2011-01-21 20:49:50 +00:00
bancika 7c5a125cd2 select components when dropped 2011-01-21 20:44:15 +00:00
bancika 3339a1b6eb added object cache 2011-01-21 20:41:08 +00:00
bancika d1603161a3 added object cache 2011-01-21 20:39:53 +00:00
bancika c51357f58c added object cache 2011-01-21 18:57:05 +00:00
bancika d67a0e7c87 fixed board collapsing bug 2011-01-21 08:44:33 +00:00
bancika 3f4aa807f0 fixed board collapsing bug 2011-01-21 08:35:18 +00:00
bancika 9ae74ac0a1 improved lead drawing 2011-01-20 23:34:33 +00:00
bancika be7e9a1d53 do not drag while creating new component 2011-01-20 23:23:40 +00:00
bancika dd53cfe569 don't allow selection rect when creating new
update selection when dropped
2011-01-20 21:52:51 +00:00
bancika 90f760dcd1 naming 2011-01-20 21:47:09 +00:00
bancika c875060e6a fixed compiler warning 2011-01-20 21:44:36 +00:00
bancika 0aeaa0dea0 refactored selection code 2011-01-20 21:40:53 +00:00
bancika 0c92d76d99 changed status text formatting 2011-01-20 21:24:07 +00:00
bancika a315bc06fa refactored instantiation code out the presenter 2011-01-20 21:19:32 +00:00
bancika 2309e80edc ctrl to unstuck components 2011-01-20 20:33:42 +00:00
bancika e0fd55c374 added component slot while creating
invalidate components when deleted
2011-01-20 19:03:04 +00:00
bancika 419293a956 fixed pdf scaling
changed few colors
2011-01-20 00:12:16 +00:00
bancika 55f7d2e057 added grid type
renamed few classes
2011-01-19 19:38:36 +00:00
bancika 69ef633af3 improved lead looks 2011-01-19 18:58:38 +00:00
bancika e38fb84621 boards don't disappear when points are flipped 2011-01-19 18:47:15 +00:00
bancika d4f2662bde fixed ghost painting 2011-01-19 18:42:08 +00:00
bancika be9a47753c removed old class 2011-01-19 18:30:20 +00:00
bancika 15b03b12a5 refactored file management out of presenter 2011-01-19 18:28:31 +00:00
bancika 69e961b296 refactored file management out of presenter 2011-01-19 18:24:13 +00:00
bancika 0d6fa98221 removed log for memory tracking 2011-01-19 18:14:37 +00:00
bancika 8a83bca7f2 do not show unnecessary decimals 2011-01-18 20:51:57 +00:00
bancika 7f1f7b60a5 fixed editing units 2011-01-18 20:39:28 +00:00
bancika 5e88aeedc1 2011-01-18 20:35:13 +00:00
bancika 8c4c884062 use enter and escape in the editor dialog 2011-01-17 23:14:33 +00:00
bancika fb46acad60 Adjust label angle if needed to make sure that it's readable 2011-01-17 23:07:46 +00:00
bancika a2ea8ee393 control point collision detection 2011-01-17 22:58:35 +00:00
bancika 5cea9f0193 persist zoom level 2011-01-17 22:48:43 +00:00
bancika b9aeaff6da bom tweak
anti-aliasing made as configurable item
2011-01-17 22:28:43 +00:00
bancika e866762b05 always show control point when creating new component
changed board alignment
fixed sticking to non-stickable points
2011-01-17 20:24:29 +00:00
bancika dcb5b668db fix main class 2011-01-17 19:57:31 +00:00
bancika f37e0dfc95 setup sticky and visibility policy for each point inidividually 2011-01-17 19:46:42 +00:00
bancika 7ad87076d3 added icons, fixed donate option 2011-01-17 19:20:02 +00:00
bancika 6dba12eab8 board improvements
show point for non-stretchable components too
2011-01-17 00:19:47 +00:00
bancika c02b37bcba fixed modified flag on drag end 2011-01-16 23:26:17 +00:00
bancika 584d84ff77 improved display of control points and status message 2011-01-16 23:18:15 +00:00
bancika 796276b1c1 object optimization 2011-01-16 23:08:31 +00:00
bancika c3d5556121 improved point-by-point creation 2011-01-16 23:04:32 +00:00
bancika 5b0eb295c8 show directories in file choosers 2011-01-16 21:17:03 +00:00
bancika 1d0f393931 added point by point component creation 2011-01-16 21:11:41 +00:00
bancika 8186841851 improved vero board 2011-01-16 13:35:53 +00:00
bancika 2478c7e51b temporary disable accessory in file choosers 2011-01-16 13:35:29 +00:00
bancika 1b2495f23e fixed save and save as to update the title bar 2011-01-16 13:28:34 +00:00
bancika 2af10da63c refactor drawing code out of presenter 2011-01-16 13:28:15 +00:00
bancika 6da2a6e94c refactor drawing code out of presenter 2011-01-16 13:27:45 +00:00
bancika 2660841ceb allow choosing name/value 2011-01-16 09:50:00 +00:00
bancika 6f6d802829 hotspot tracking optimization 2011-01-16 09:32:34 +00:00
bancika b81d633ce5 improve curve detection 2011-01-16 09:07:01 +00:00
bancika 63cf354c25 fixed paste translation 2011-01-16 08:47:17 +00:00
bancika e1377a8b09 painting optimization 2011-01-16 08:45:22 +00:00
bancika 1781c45317 outline optimization 2011-01-16 08:38:10 +00:00
bancika 7fd817191b optimize selection rect 2011-01-15 21:52:53 +00:00
bancika e8048d9d94 fix board name 2011-01-15 21:50:27 +00:00
bancika 657ce2e580 use acceleration 2011-01-15 21:48:36 +00:00
bancika 60e0ce6392 painting optimization 2011-01-15 21:05:31 +00:00
bancika 0ceed9a93a sort properties for project 2011-01-15 20:51:30 +00:00
bancika a470fb2abd title and desc non defaultable 2011-01-15 20:50:12 +00:00
bancika c8796102d9 moved utility method 2011-01-15 20:48:23 +00:00
bancika 1efe629f3d version # 2011-01-15 20:42:35 +00:00
bancika e9bcae11e3 improve paste 2011-01-15 20:41:31 +00:00
bancika 03444c3146 added helper methods for config reader 2011-01-15 20:32:46 +00:00
bancika 84818eef6a refresh selection on delete 2011-01-15 15:38:55 +00:00
bancika 3759fbc1ba allow expressions in double text field 2011-01-15 15:35:45 +00:00
bancika f05c3ccc86 save project default properties 2011-01-15 15:05:07 +00:00
bancika b99d438eb8 checks for file modifications 2011-01-15 14:19:36 +00:00
bancika 52df431beb checks for file modifications 2011-01-15 14:04:33 +00:00
bancika d16ee1d890 added menu item to edit selection 2011-01-15 11:13:19 +00:00
bancika cb1155e8fa fixed rounding to grid 2011-01-15 10:33:16 +00:00
bancika c677e98cad editable project properties 2011-01-15 10:31:07 +00:00
bancika dd4080accb make grid spacing flexible 2011-01-15 10:11:09 +00:00
bancika c8de2aa271 improved color editor 2011-01-14 16:23:00 +00:00
bancika 4420a97993 fixed double text field warning icon 2011-01-14 14:02:58 +00:00
bancika 1f5fa8ae14 fixed measure editing
fixed trace lead color
2011-01-14 13:57:51 +00:00
bancika 628d370019 changed about dialog 2011-01-14 13:41:55 +00:00
bancika 9652059ce7 added help items 2011-01-14 13:36:10 +00:00
bancika 8bc851875d added help items 2011-01-14 13:22:18 +00:00
bancika acf5b78a6c added help items 2011-01-14 13:21:44 +00:00
bancika d91d7baff3 added trace mask icon 2011-01-14 13:02:28 +00:00
bancika 0976a25c88 added trace mask icon 2011-01-14 12:49:51 +00:00
bancika a399fedfd7 improved d&d 2011-01-14 12:38:50 +00:00
bancika ef443925c2 added export trace
improved status message on selection
2011-01-14 10:00:04 +00:00
bancika e5c0b01aca include stuck components in drag 2011-01-13 21:34:45 +00:00
bancika f3ed8d1a7c tweak colors 2011-01-13 18:50:27 +00:00
bancika 7afeb48407 impoved bom 2011-01-12 23:59:34 +00:00
bancika 2dc7a50e2f zoom level doesn't reflect in the rulers 2011-01-12 23:57:47 +00:00
bancika aac45e8978 added project info component 2011-01-12 23:01:35 +00:00
bancika b9e5704225 improved few components 2011-01-12 22:48:00 +00:00
bancika 521e3fda5f added bom component 2011-01-12 20:50:13 +00:00
bancika 23f4cb7468 fixed npe 2011-01-12 20:43:51 +00:00
bancika dd1ec04f1c track string drawing 2011-01-12 20:43:40 +00:00
bancika f050ab5818 doc 2011-01-12 18:25:44 +00:00
bancika 09e4862bcc grouping improvement 2011-01-12 17:46:57 +00:00
bancika 27bac25c8b added group/ungroup 2011-01-12 00:39:39 +00:00
bancika a04c90b689 update prefixes 2011-01-11 23:38:35 +00:00
bancika d2bacdaa21 add ant build 2011-01-11 23:36:29 +00:00
bancika f8dd6a36c0 update prefixes 2011-01-11 23:31:25 +00:00
bancika 5d22d282fa use red when selected 2011-01-11 21:48:38 +00:00
bancika 19d561d35d show selection in status bar 2011-01-11 21:34:15 +00:00
bancika 070e3edf52 use red when selected 2011-01-11 21:22:07 +00:00
bancika e3a3dfe82e use red rectangle when selected 2011-01-11 19:22:48 +00:00
bancika a97f83f1ac use red rectangle when selected 2011-01-11 19:21:05 +00:00
bancika 37a7362d9e fixed d&d bug with multiple selection 2011-01-11 18:54:53 +00:00
bancika e9936e4adb select all works now 2011-01-11 18:47:40 +00:00
bancika cb72d596a3 editable colors for boards 2011-01-10 23:47:39 +00:00
bancika ce63511188 editable colors for boards 2011-01-10 23:43:01 +00:00
bancika c2e5b6d20c improved switch and IC 2011-01-10 23:32:47 +00:00
bancika dcbd351589 improved switch 2011-01-10 23:12:07 +00:00
bancika 56beaa7f9b draw leads on the top, useful for radial components 2011-01-10 23:06:23 +00:00
bancika c4cedd8946 better measure 2011-01-10 22:51:26 +00:00
bancika d141b9c477 added delete functionality 2011-01-10 22:38:50 +00:00
bancika e249667bbd allow custom cm and in spacing
more precise ruler
2011-01-10 19:45:05 +00:00
bancika ee01f390da better measurement 2011-01-10 19:37:13 +00:00
bancika 3fd425f2cd removed old code 2011-01-10 18:48:17 +00:00
bancika e17c0d5753 abstract class reorganization
sort properties by name
2011-01-10 18:43:23 +00:00
bancika dc1f0ac7bd 2011-01-10 18:32:14 +00:00
bancika 13cfcb16df editable board spacing 2011-01-10 18:31:24 +00:00
bancika 218126c85e renamed class 2011-01-10 18:26:49 +00:00
bancika e7784f442b added abstract curve 2011-01-10 00:07:22 +00:00
bancika 573b58902b jumper to blue 2011-01-09 23:49:58 +00:00
bancika 974c5bcf21 added trace cut 2011-01-09 23:38:55 +00:00
bancika 481c28d835 fixed npe 2011-01-09 23:38:37 +00:00
bancika 5f860348df change layer to double
added solder pad
2011-01-09 23:10:24 +00:00
bancika 7af112a28b added ic pins 2011-01-09 14:28:02 +00:00
bancika c898fee28e added color properties to abstract leaded comp 2011-01-09 13:11:46 +00:00
bancika f2fa8195b3 added some icons 2011-01-09 12:44:24 +00:00
bancika 41bcfec45e added some icons 2011-01-09 12:44:07 +00:00
bancika 32efad1490 process polygon line 2011-01-09 12:19:44 +00:00
bancika 6a80bcdbe6 process shape outline 2011-01-09 12:16:53 +00:00
bancika 37a74f7918 added wire 2011-01-09 12:16:27 +00:00
bancika 94c53a2344 doc 2011-01-09 00:46:24 +00:00
bancika 672aef6799 2011-01-09 00:42:00 +00:00
bancika 9a2fdc264f disable alpha on jumpers 2011-01-09 00:39:04 +00:00
bancika d43e098216 added transparency 2011-01-09 00:08:13 +00:00
bancika 300753bb85 sort categories 2011-01-08 19:24:06 +00:00
bancika fa2709efc0 moved logic to component processor 2011-01-08 18:37:11 +00:00
bancika 43d931a1e6 cleanup 2011-01-08 18:31:36 +00:00
bancika 4dd470f185 support for line recognition
recognize deprecated properties
2011-01-08 18:22:36 +00:00
bancika f3bc414676 Added jumper and trace 2011-01-08 18:19:57 +00:00
bancika 0b319cf46f 2011-01-08 15:50:51 +00:00
bancika 90e8f4004b changed switch 2011-01-08 15:48:15 +00:00
bancika 80fff261bb removed old code 2011-01-08 15:39:22 +00:00
bancika ad43ecd0ed added selection size 2011-01-08 15:35:33 +00:00
bancika a4309a169c fixed z-order selection 2011-01-08 14:18:05 +00:00
bancika ca1d71e2eb draw control points on the top 2011-01-08 14:13:55 +00:00
bancika 695887ba4c do not show control points of non-stretchable 2011-01-08 14:10:24 +00:00
bancika 33d03a377d do not look for setter if no annotation is found 2011-01-08 14:06:18 +00:00
bancika 2d942a3214 moved common code to the main project 2011-01-08 14:02:53 +00:00
bancika 746b7d4e97 reorganized packages
added toggle switch
2011-01-08 14:02:21 +00:00
bancika 8a115e5cbd fixed d&d jumping issue when zoomed 2011-01-08 14:00:56 +00:00
bancika 93ac7b24d1 Code cleanup 2011-01-08 10:56:59 +00:00
bancika a91e2c2617 fixed d&d jumping issue 2011-01-08 10:55:08 +00:00
bancika 69f1e8afcd Z-order component handling 2011-01-08 10:17:01 +00:00
bancika d2cc7cd214 Z-order component handling 2011-01-08 10:16:17 +00:00
bancika e0a3a64696 fixed dynamic jar loading 2011-01-08 10:03:27 +00:00
bancika b9fe3d84e2 Z-order component handling 2011-01-08 09:34:21 +00:00
bancika 5b0753c42c improved perfboard 2011-01-08 09:33:27 +00:00
bancika d4cece7f5a improved perfboard 2011-01-08 09:02:48 +00:00
bancika 435f8d62f2 added boards 2011-01-07 17:03:39 +00:00
bancika a5c5296365 moving library to new project 2011-01-07 16:37:37 +00:00
bancika a6b378c173 2011-01-07 16:34:40 +00:00
bancika defd97118a IC painting issue fix 2011-01-06 00:42:32 +00:00
bancika 53433f0836 increased repaint hack time 2011-01-06 00:39:52 +00:00
bancika e612b39b26 better d&d of control points
doc
2011-01-06 00:23:59 +00:00
bancika b33d1c3e37 improved IC 2011-01-05 23:54:57 +00:00
bancika 3b3a9baa82 warning fixed 2011-01-05 19:43:48 +00:00
bancika 1b3457623d warning fixed 2011-01-05 19:42:18 +00:00
bancika 7bd3245024 added enum editor 2011-01-05 19:41:32 +00:00
bancika 51eee908c2 changed control point api 2011-01-05 19:21:59 +00:00
bancika 8db24c2588 added project to component.draw
better logging
2011-01-05 01:00:16 +00:00
bancika dd50ccf785 simplified component framework 2011-01-05 00:20:09 +00:00
bancika 69acfcff2f simplified component framework 2011-01-05 00:09:11 +00:00
bancika d1892cae70 added more capacitors 2011-01-04 22:58:04 +00:00
bancika 2c994228f4 added more capacitors 2011-01-04 22:54:57 +00:00
bancika 74c7007b23 added capacitor 2011-01-04 22:47:41 +00:00
bancika 872293ea0e doc 2011-01-04 22:29:10 +00:00
bancika cb5c95478f abstract leaded component changes 2011-01-04 22:19:24 +00:00
bancika 2bd2ecd13d renamed BOM objects 2011-01-04 21:13:13 +00:00
bancika 32409b186f doc 2011-01-04 21:01:46 +00:00
bancika a88f0d0a45 refactored component framework 2011-01-04 20:55:35 +00:00
bancika 73da0f4a9b 2011-01-04 19:07:30 +00:00
304 changed files with 12162 additions and 3685 deletions
+1 -2
View File
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="src" path="src.library"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
@@ -11,8 +10,8 @@
<classpathentry kind="lib" path="lib/cloning-1.5.jar"/>
<classpathentry kind="lib" path="lib/objenesis-1.1.jar"/>
<classpathentry kind="lib" path="lib/bancika-gui-framework.jar"/>
<classpathentry kind="lib" path="lib/HttpProxy.jar"/>
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
<classpathentry kind="lib" path="lib/poi-3.5-FINAL-20090928.jar"/>
<classpathentry kind="lib" path="library/main.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View File
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="bad_container_name" value="\DIYLC\r"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/DIYLC/src/org/diylc/DIYLCStarter.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;Library&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;DIYLC&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.diylc.DIYLCStarter"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="DIYLC"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx512m"/>
</launchConfiguration>
+7 -1
View File
@@ -5,7 +5,7 @@
<property name="build.dir" value="${basedir}/build" />
<property name="jar.dir" value="${build.dir}/jar" />
<property name="report.dir" value="${build.dir}/junitreport" />
<property name="main.class" value="com.diyfever.diylc.DIYLCStarter" />
<property name="main.class" value="org.diylc.DIYLCStarter" />
<property name="classes.dir" value="${build.dir}/temp/${ant.project.name}/classes" />
<property name="test.classes.dir" value="${build.dir}/temp/${ant.project.name}/test.classes" />
@@ -35,6 +35,11 @@
<exclude name="**/*dll" />
</fileset>
</copy>
<copy todir="${jar.dir}/library" overwrite="true">
<fileset dir="${basedir}/library">
<exclude name="**/*dll" />
</fileset>
</copy>
<copy todir="${jar.dir}" overwrite="true">
<fileset dir="${basedir}/lib/" includes="**/*.dll" />
</copy>
@@ -43,6 +48,7 @@
<path id="class.path">
<fileset dir="${basedir}">
<include name="lib/**/*.jar" />
<include name="library/**/*.jar" />
</fileset>
</path>
+2
View File
@@ -0,0 +1,2 @@
#org.diylc.utils.Constants.CANVAS_COLOR=#005D96
#org.diylc.utils.Constants.GRID_COLOR=#FFFFFF
+22
View File
@@ -0,0 +1,22 @@
<map>
<entry>
<string>lastPath</string>
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop\oldFiles</string>
</entry>
<entry>
<string>zoom</string>
<double>1.0</double>
</entry>
<entry>
<string>metric</string>
<boolean>true</boolean>
</entry>
<entry>
<string>showTemplatesAtStartup</string>
<boolean>false</boolean>
</entry>
<entry>
<string>default.org.diylc.components.semiconductors.TransistorTO92:Orientation</string>
<org.diylc.common.Orientation>DEFAULT</org.diylc.common.Orientation>
</entry>
</map>
Binary file not shown.
+74
View File
@@ -0,0 +1,74 @@
package org.diylc;
import java.io.FileInputStream;
import java.net.URL;
import java.util.Properties;
import javax.swing.UIManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.diylc.presenter.Presenter;
import org.diylc.swing.gui.MainFrame;
import org.diylc.swing.gui.TemplateDialog;
import com.diyfever.gui.miscutils.ConfigurationManager;
import com.diyfever.gui.miscutils.PropertyInjector;
/**
* Main class that runs DIYLC.
*
* @author Branislav Stojkovic
*
* @see Presenter
* @see MainFrame
*/
public class DIYLCStarter {
private static final Logger LOG = Logger.getLogger(Presenter.class);
/**
* @param args
*/
public static void main(String[] args) {
URL url = DIYLCStarter.class.getResource("log4j.properties");
Properties properties = new Properties();
try {
properties.load(url.openStream());
PropertyConfigurator.configure(properties);
} catch (Exception e) {
LOG.error("Could not initialize log4j configuration", e);
}
LOG.info("Starting DIYLC with working directory " + System.getProperty("user.dir"));
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
LOG.error("Could not set Look&Feel", e);
}
MainFrame mainFrame = new MainFrame();
mainFrame.setLocationRelativeTo(null);
mainFrame.setVisible(true);
boolean showTemplates = ConfigurationManager.getInstance().readBoolean(
TemplateDialog.SHOW_TEMPLATES_KEY, true);
if (showTemplates) {
TemplateDialog templateDialog = new TemplateDialog(mainFrame, mainFrame.getPresenter());
if (!templateDialog.getFiles().isEmpty()) {
templateDialog.setVisible(true);
}
}
url = DIYLCStarter.class.getResource("/config.properties");
properties = new Properties();
try {
LOG.info("Injecting default properties.");
properties.load(new FileInputStream("config.properties"));
PropertyInjector.injectProperties(properties);
} catch (Exception e) {
LOG.error("Could not read config.properties file", e);
}
}
}
@@ -0,0 +1,88 @@
package org.diylc.common;
import javax.swing.Icon;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent;
/**
* Entity class used to describe a component type.
*
* @author Branislav Stojkovic
*
* @see IDIYComponent
*/
public class ComponentType {
private String name;
private String description;
private CreationMethod creationMethod;
private String category;
private String namePrefix;
private String author;
private Icon icon;
private Class<? extends IDIYComponent<?>> instanceClass;
private double zOrder;
private boolean stretchable;
public ComponentType(String name, String description, CreationMethod creationMethod,
String category, String namePrefix, String author, Icon icon,
Class<? extends IDIYComponent<?>> instanceClass, double zOrder, boolean stretchable) {
super();
this.name = name;
this.description = description;
this.creationMethod = creationMethod;
this.category = category;
this.namePrefix = namePrefix;
this.author = author;
this.icon = icon;
this.instanceClass = instanceClass;
this.zOrder = zOrder;
this.stretchable = stretchable;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public CreationMethod getCreationMethod() {
return creationMethod;
}
public String getCategory() {
return category;
}
public String getNamePrefix() {
return namePrefix;
}
public String getAuthor() {
return author;
}
public Icon getIcon() {
return icon;
}
public Class<? extends IDIYComponent<?>> getInstanceClass() {
return instanceClass;
}
public double getZOrder() {
return zOrder;
}
public boolean isStretchable() {
return stretchable;
}
@Override
public String toString() {
return name;
}
}
+11
View File
@@ -0,0 +1,11 @@
package org.diylc.common;
public enum Display {
NAME, VALUE;
@Override
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
@@ -5,7 +5,7 @@ import java.awt.Graphics;
/**
* Enumerates all options that can be used when drawing a project.
*
* @see IPlugInPort#draw(java.awt.Graphics2D, java.util.EnumSet)
* @see IPlugInPort#draw(java.awt.Graphics2D, java.util.Set, IComponentFiler)
*
* @author Branislav Stojkovic
*/
@@ -1,10 +1,9 @@
package org.diylc.common;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import org.diylc.model.IComponentType;
import org.diylc.model.Project;
import org.diylc.core.Project;
/**
* Enumerates all possible events between {@link IPlugInPort} and
@@ -27,6 +26,12 @@ public enum EventType {
* or loaded with undo/redo operations.
*/
PROJECT_LOADED,
/**
* Called when either current file name or modified flag are changed. The
* first parameter is the current file name, the second one is a boolean
* modified flag.
*/
FILE_STATUS_CHANGED,
/**
* Called when selection rectangle is changed. Object of type
* {@link Rectangle} is the only parameter and it contains the new selection
@@ -39,12 +44,14 @@ public enum EventType {
*/
SELECTION_CHANGED,
/**
* Called when display needs to be repainted. No parameters are passed.
* Called when selection size changes, together with a {@link Point2D}
* object containing selection size (x = width, y = height). Size is
* expressed in the default measure (cm for metric, inches for imperial).
*/
REPAINT,
/**
* Called when new component slot has been changed. The only parameter is
* {@link IComponentType} and may be null.
* {@link ComponentType} and may be null.
*/
SLOT_CHANGED,
/**
@@ -52,5 +59,25 @@ public enum EventType {
* {@link Project} are passed as parameters, one before and one after the
* change. The third parameter is a string containing change description.
*/
PROJECT_MODIFIED, AVAILABLE_CTRL_POINTS_CHANGED, SELECTED_CTRL_POINTS_CHANGED, ;
PROJECT_MODIFIED,
/**
* Called when control points under the cursor are changed. A single
* parameter is passed, an instance of
* <code>Map<IDIYComponent<?>, Set<Integer>></code> containing all the
* components and indices of their control points that are under the cursor.
*/
AVAILABLE_CTRL_POINTS_CHANGED,
/**
* Called when mouse cursor is moved. Point object is passed, containing the
* current cursor location (not taking zoom into account).
*/
MOUSE_MOVED,
/**
* Called when a layer status is changed. The first parameter is a set of indices of locked layers. All layers not included are considered unlocked.
*/
LAYER_STATE_CHANGED,
/**
* Called to update the status message. New status message is passed as a first parameter.
*/
STATUS_MESSAGE_CHANGED;
}
+6
View File
@@ -0,0 +1,6 @@
package org.diylc.common;
public enum GridType {
LINES, CROSSHAIR, DOT, NONE;
}
@@ -0,0 +1,8 @@
package org.diylc.common;
import org.diylc.core.IDIYComponent;
public interface IComponentFiler {
boolean testComponent(IDIYComponent<?> component);
}
@@ -4,20 +4,13 @@ import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.Area;
import java.awt.geom.Point2D;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.Action;
import javax.swing.JComponent;
import javax.swing.SwingConstants;
import javax.swing.JPopupMenu.Separator;
import org.diylc.model.ComponentLayer;
import org.diylc.model.IComponentInstance;
import org.diylc.model.IComponentType;
import org.diylc.model.Project;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import com.diyfever.gui.simplemq.IMessageListener;
import com.diyfever.gui.simplemq.MessageDispatcher;
@@ -37,6 +30,8 @@ import com.diyfever.gui.update.VersionNumber;
*/
public interface IPlugInPort {
public static final String CHECK_BOX_MENU_ITEM = "org.diylc.checkBoxMenuItem";
/**
* 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
@@ -76,52 +71,63 @@ public interface IPlugInPort {
void loadProject(Project project, boolean freshStart);
/**
* Returns all available {@link IComponentType}s classified by category.
* Creates a new project.
*/
void createNewProject();
/**
* Loads a project from the specified file.
*
* @param fileName
*/
void loadProjectFromFile(String fileName);
/**
* Saves the current project into the specified file.
*
* @param fileName
*/
void saveProjectToFile(String fileName);
/**
* @return the current file name.
*/
String getCurrentFileName();
/**
* @return true if the current project is modified.
*/
boolean isProjectModified();
/**
* 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();
/**
* Returns all available {@link ComponentType}s classified by category.
* Result is a {@link Map} between category name to a {@link List} of all
* {@link IComponentType}s that share that category name.
* {@link ComponentType}s that share that category name.
*
* @return
*/
Map<String, List<IComponentType>> getComponentTypes();
Map<String, List<ComponentType>> getComponentTypes();
/**
* Draws project on the provided {@link Graphics2D}.
* 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
*/
void draw(Graphics2D g2d, Set<DrawOption> drawProperties);
void draw(Graphics2D g2d, Set<DrawOption> drawOptions, IComponentFiler filter);
/**
* Injects a custom GUI panels provided by the plug-in and desired position
* in the window. Application will layout plug-in panels accordingly. <br>
* Valid positions are:
* <ul>
* <li> {@link SwingConstants#TOP}</li>
* <li> {@link SwingConstants#BOTTOM}</li>
* <li> {@link SwingConstants#LEFT}</li>
* <li> {@link SwingConstants#RIGHT}</li>
* </ul>
*
* Center position is reserved for the main canvas panel and cannot be used.
*
* @param component
* @param position
* @throws BadPositionException
* in case invalid position is specified
*/
void injectGUIComponent(JComponent component, int position) throws BadPositionException;
/**
* Injects a custom menu action into application's main menu. If
* <code>action</code> is set to null {@link Separator} will be added. If
* the specified menu does not exist it will be automatically created.
*
* @param action
* {@link Action} to inser
* @param menuName
* name of the menu to insert into
*/
public void injectMenuAction(Action action, String menuName);
Double[] getAvailableZoomLevels();
/**
* Returns current zoom level where <code>zoomLevel = 1.0d</code> means
@@ -164,18 +170,16 @@ public interface IPlugInPort {
void mouseMoved(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown);
/**
* Returns the current {@link ComponentSelection}.
* Returns the current {@link ComponentTransferable}.
*
* @return
*/
ComponentSelection getSelectedComponents();
List<IDIYComponent<?>> getSelectedComponents();
/**
* Returns the {@link Area} occupied by the component.
*
* @return
* Selects all components in the project.
*/
Area getComponentArea(IComponentInstance component);
void selectAll();
/**
* Notification that drag has been started from the specified point.
@@ -183,8 +187,11 @@ public interface IPlugInPort {
* Note: point coordinates are scaled for zoom factor.
*
* @param point
* @param ctrlDown
* @param shiftDown
* @param altDown
*/
void dragStarted(Point point);
void dragStarted(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown);
/**
* Checks if it's possible to drop over the specified point.
@@ -216,41 +223,13 @@ public interface IPlugInPort {
* Adds a list of components to the project.
*
* @param components
* @param preferredPoint
*/
void addComponents(List<IComponentInstance> components, Point preferredPoint);
void pasteComponents(List<IDIYComponent<?>> components);
/**
* Checks if a certain layer is locked for editing.
*
* @param layer
* @return
* Deletes all the selected components from the project.
*/
boolean isLayerLocked(ComponentLayer layer);
/**
* Changes layer's locked state.
*
* @param layer
* @param locked
*/
void setLayerLocked(ComponentLayer layer, boolean locked);
/**
* Checks if a certain layer is visible.
*
* @param layer
* @return
*/
boolean isLayerVisible(ComponentLayer layer);
/**
* Changes layer visibility.
*
* @param layer
* @param visible
*/
void setLayerVisible(ComponentLayer layer, boolean visible);
void deleteSelectedComponents();
/**
* Sets default value for the specified property name for currently selected
@@ -261,14 +240,23 @@ public interface IPlugInPort {
* @param value
* new default value, must not be null
*/
void setDefaultPropertyValue(String propertyName, Object value);
void setSelectionDefaultPropertyValue(String propertyName, Object value);
/**
* Returns a list of properties that are mutual for all the selected
* components. Resulting list may be empty if selected components do not
* have mutual properties or can be null if the selection is empty.
* Sets default value for the specified property name for projects.
*
* @return
* @param propertyName
* display name for property
* @param value
* new default value, must not be null
*/
void setProjectDefaultPropertyValue(String propertyName, Object value);
/**
* @return a list of properties that are mutual for all the selected
* components. Resulting list may be empty if selected components do
* not have mutual properties or can be null if the selection is
* empty.
*/
List<PropertyWrapper> getMutualSelectionProperties();
@@ -278,15 +266,66 @@ public interface IPlugInPort {
* exception will be thrown.
*
* @param properties
* @throws Exception
*/
void applyPropertiesToSelection(List<PropertyWrapper> properties) throws Exception;
void applyPropertiesToSelection(List<PropertyWrapper> properties);
// void setCursorIcon(Icon icon);
/**
* @return a list of editable properties of the current project.
*/
List<PropertyWrapper> getProjectProperties();
/**
* Applies specified properties to the current project.
*
* @param properties
*/
void applyPropertiesToProject(List<PropertyWrapper> properties);
/**
* Sets the new component slot. Specified component type will be used to
* instantiate new component.
*/
void setNewComponentSlot(IComponentType componentType);
void setNewComponentTypeSlot(ComponentType componentType);
/**
* Changes default size notation, true for metric, false for imperial.
*
* @param isMetric
*/
void setMetric(boolean isMetric);
/**
* Groups all selected components.
*/
void groupSelectedComponents();
/**
* Ungroups all selected components.
*/
void ungroupSelectedComponents();
/**
* Locks or unlocks the specified layer. All components within +- 0.5 range
* will be affected by the change as well.
*
* @param layerZOrder
* @param locked
*/
void setLayerLocked(int layerZOrder, boolean locked);
/**
* @return selection size expressed in either inches or centimeters, based
* on the user preference.
*/
Point2D calculateSelectionDimension();
/**
* Sends each of the selected components one step back.
*/
void sendSelectionToBack();
/**
* Brings each of the selected components one step to front.
*/
void bringSelectionToFront();
}
+34
View File
@@ -0,0 +1,34 @@
package org.diylc.common;
/**
* Abstract layer between the app and platform worker thread implementation.
*
* @author Branislav Stojkovic
*
* @param <T>
*/
public interface ITask<T> {
/**
* Runs in background thread.
*
* @return
* @throws Exception
*/
T doInBackground() throws Exception;
/**
* Called if background thread fails.
*
* @param e
*/
void failed(Exception e);
/**
* Called if background thread is executed correctly, the result is passed
* as a parameter.
*
* @param result
*/
void complete(T result);
}
@@ -0,0 +1,39 @@
package org.diylc.common;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Stroke;
import java.util.HashMap;
import java.util.Map;
/**
* Repository for object that may be reused, such as {@link Stroke} or
* {@link AlphaComposite}.
*
* @author Branislav Stojkovic
*/
public class ObjectCache {
private static ObjectCache instance;
public static ObjectCache getInstance() {
if (instance == null) {
instance = new ObjectCache();
}
return instance;
}
private ObjectCache() {
}
private Map<Integer, Stroke> basicStrokeMap = new HashMap<Integer, Stroke>();
public Stroke fetchBasicStroke(int width) {
if (basicStrokeMap.containsKey(width)) {
return basicStrokeMap.get(width);
}
Stroke stroke = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
basicStrokeMap.put(width, stroke);
return stroke;
}
}
@@ -0,0 +1,15 @@
package org.diylc.common;
public enum Orientation {
DEFAULT, _90, _180, _270;
@Override
public String toString() {
if (this == DEFAULT) {
return "Default";
} else {
return name().replace("_", "") + " degrees clockwise";
}
}
}
+5
View File
@@ -0,0 +1,5 @@
package org.diylc.common;
public enum Power {
}
@@ -3,8 +3,7 @@ package org.diylc.common;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.diylc.model.IComponentInstance;
import org.diylc.core.IPropertyValidator;
/**
* Entity class for editable properties extracted from component objects.
@@ -20,23 +19,25 @@ public class PropertyWrapper implements Cloneable {
private Method setter;
private Method getter;
private boolean defaultable;
private IPropertyValidator validator;
public PropertyWrapper(String name, Class<?> type, Method getter, Method setter,
boolean defaultable) {
boolean defaultable, IPropertyValidator validator) {
super();
this.name = name;
this.type = type;
this.getter = getter;
this.setter = setter;
this.defaultable = defaultable;
this.validator = validator;
}
public void readFrom(IComponentInstance component) throws IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
this.value = getter.invoke(component);
public void readFrom(Object object) throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException {
this.value = getter.invoke(object);
}
// public void readUniqueFrom(IComponentInstance component)
// public void readUniqueFrom(IDIYComponent component)
// throws IllegalArgumentException, IllegalAccessException,
// InvocationTargetException {
// Object newValue = getter.invoke(component);
@@ -45,9 +46,9 @@ public class PropertyWrapper implements Cloneable {
// }
// }
public void writeTo(IComponentInstance component) throws IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
setter.invoke(component, value);
public void writeTo(Object object) throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException {
setter.invoke(object, value);
}
public String getName() {
@@ -70,8 +71,8 @@ public class PropertyWrapper implements Cloneable {
return defaultable;
}
public void setDefaultable(boolean defaultable) {
this.defaultable = defaultable;
public IPropertyValidator getValidator() {
return validator;
}
// @Override
@@ -0,0 +1,14 @@
package org.diylc.common;
public enum ResistorColorCode {
NONE, _4_BAND, _5_BAND;
@Override
public String toString() {
if (name().startsWith("_")) {
return name().substring(1).replace("_", " ").toLowerCase();
}
return name().substring(0, 1).toUpperCase() + name().substring(1).toLowerCase();
}
}
@@ -0,0 +1,59 @@
package org.diylc.components;
import java.awt.Color;
import java.awt.Font;
import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.EditableProperty;
/**
* Abstract implementation of {@link IDIYComponent} that contains component name
* and toString.
*
* @author Branislav Stojkovic
*
* @param <T>
*/
public abstract class AbstractComponent<T> implements IDIYComponent<T> {
private static final long serialVersionUID = 1L;
protected String name = "";
public static Color SELECTION_COLOR = Color.red;
public static Color LABEL_COLOR = Color.black;
public static Color LABEL_COLOR_SELECTED = Color.red;
public static Font LABEL_FONT = new Font("Tahoma", Font.PLAIN, 12);
@EditableProperty(defaultable = false)
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public boolean canControlPointOverlap(int index) {
return false;
}
@Override
public String toString() {
return name;
}
/**
* Returns the closest odd number, i.e. x when x is odd, or x + 1 when x is
* even.
*
* @param x
* @return
*/
protected int getClosestOdd(int x) {
return (x / 2) * 2 + 1;
}
}
@@ -0,0 +1,136 @@
package org.diylc.components;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.CubicCurve2D;
import org.diylc.common.ObjectCache;
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> {
private static final long serialVersionUID = 1L;
public static Color GUIDELINE_COLOR = Color.blue;
public static Size DEFAULT_SIZE = new Size(1d, SizeUnit.in);
protected Point[] controlPoints = new Point[] { new Point(0, 0),
new Point(DEFAULT_SIZE.convertToPixels() / 2, 0),
new Point(DEFAULT_SIZE.convertToPixels() / 2, DEFAULT_SIZE.convertToPixels()),
new Point(DEFAULT_SIZE.convertToPixels(), DEFAULT_SIZE.convertToPixels()) };
protected Color color = getDefaultColor();
/**
* Draws the specified curve onto graphics.
*
* @param curve
* @param g2d
* @param componentState
*/
protected abstract void drawCurve(CubicCurve2D curve, Graphics2D g2d,
ComponentState componentState);
/**
* @return default color.
*/
protected abstract Color getDefaultColor();
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
g2d.setColor(getDefaultColor().darker());
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(3));
CubicCurve2D curve = new CubicCurve2D.Double(1, height - 1, width / 4, height / 3,
3 * width / 4, 2 * height / 3, width - 1, 1);
g2d.draw(curve);
g2d.setColor(getDefaultColor());
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
g2d.draw(curve);
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
IDrawingObserver drawingObserver) {
if (componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING) {
// Do not track guidelines.
drawingObserver.stopTracking();
g2d.setStroke(Constants.DASHED_STROKE);
g2d.setColor(GUIDELINE_COLOR);
g2d.drawLine(controlPoints[0].x, controlPoints[0].y, controlPoints[1].x,
controlPoints[1].y);
g2d.drawLine(controlPoints[1].x, controlPoints[1].y, controlPoints[2].x,
controlPoints[2].y);
g2d.drawLine(controlPoints[2].x, controlPoints[2].y, controlPoints[3].x,
controlPoints[3].y);
drawingObserver.startTracking();
}
CubicCurve2D curve = new CubicCurve2D.Double(controlPoints[0].x, controlPoints[0].y,
controlPoints[1].x, controlPoints[1].y, controlPoints[2].x, controlPoints[2].y,
controlPoints[3].x, controlPoints[3].y);
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
/ MAX_ALPHA));
}
// g2d.setColor(color.darker());
// g2d.setStroke(new BasicStroke(thickness));
// g2d.draw(path);
// g2d.setColor(color);
// g2d.setStroke(new BasicStroke(thickness - 2));
// g2d.draw(path);
drawCurve(curve, g2d, componentState);
g2d.setComposite(oldComposite);
}
@Override
public int getControlPointCount() {
return controlPoints.length;
}
@Override
public boolean isControlPointSticky(int index) {
return index == 0 || index == 3;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.WHEN_SELECTED;
}
@Override
public boolean canControlPointOverlap(int index) {
// Only shape control points may overlap.
return index == 1 || index == 2;
}
@Override
public Point getControlPoint(int index) {
return controlPoints[index];
}
@Override
public void setControlPoint(Point point, int index) {
controlPoints[index].setLocation(point);
}
@EditableProperty
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
}
@@ -0,0 +1,249 @@
package org.diylc.components;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import org.diylc.common.Display;
import org.diylc.common.ObjectCache;
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;
/**
* Base class for all leaded components such as resistors or capacitors. Has two
* control points and draws leads between them. Also, it positions and draws the
* shape of the component as specified by a child class.
*
* @author Branislav Stojkovic
*/
public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComponent<T> {
private static final long serialVersionUID = 1L;
public static Color LEAD_COLOR = Color.decode("#236B8E");
public static Size LEAD_THICKNESS = new Size(0.6d, SizeUnit.mm);
public static Size DEFAULT_SIZE = new Size(1d, SizeUnit.in);
protected Size length;
protected Size width;
protected Point[] points = new Point[] {
new Point((int) (-DEFAULT_SIZE.convertToPixels() / 2), 0),
new Point(DEFAULT_SIZE.convertToPixels() / 2, 0) };
protected Color bodyColor = Color.white;
protected Color borderColor = Color.black;
protected Color labelColor = LABEL_COLOR;
protected Display display = Display.NAME;
protected AbstractLeadedComponent() {
super();
try {
this.length = getDefaultLength().clone();
this.width = getDefaultWidth().clone();
} catch (CloneNotSupportedException e) {
// This should never happen because Size supports cloning.
} catch (NullPointerException e) {
// This will happen if components do not have any shape.
}
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
IDrawingObserver drawingObserver) {
double distance = points[0].distance(points[1]);
Shape shape = getBodyShape();
if (shape == null) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
getLeadThickness().convertToPixels()));
g2d.setColor(shouldShadeLeads() ? getLeadColor(componentState).darker()
: getLeadColor(componentState));
g2d.drawLine(points[0].x, points[0].y, points[1].x, points[1].y);
if (shouldShadeLeads()) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(
getLeadThickness().convertToPixels() - 2));
g2d.setColor(getLeadColor(componentState));
g2d.drawLine(points[0].x, points[0].y, points[1].x, points[1].y);
}
return;
}
Rectangle shapeRect = shape.getBounds();
double leadLenght = (distance - shapeRect.width) / 2;
Double theta = Math.atan2(points[1].y - points[0].y, points[1].x - points[0].x);
// Transform graphics to draw the body in the right place and at the
// right angle.
g2d.translate((points[0].x + points[1].x - shapeRect.width) / 2,
(points[0].y + points[1].y - shapeRect.height) / 2);
g2d.rotate(theta, shapeRect.width / 2, shapeRect.height / 2);
// Draw body.
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
/ MAX_ALPHA));
}
g2d.setColor(bodyColor);
g2d.fill(shape);
decorateComponentBody(g2d);
g2d.setComposite(oldComposite);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
g2d.setColor(componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : borderColor);
g2d.draw(shape);
// Draw leads.
int leadThickness = getClosestOdd(getLeadThickness().convertToPixels());
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(leadThickness));
g2d.setColor(shouldShadeLeads() ? getLeadColor(componentState).darker()
: getLeadColor(componentState));
g2d.drawLine((int) (shapeRect.width - distance) / 2, (int) shapeRect.height / 2,
(int) ((shapeRect.width - distance) / 2 + leadLenght) - leadThickness / 2,
(int) shapeRect.height / 2);
g2d.drawLine((int) (shapeRect.width + distance) / 2, (int) shapeRect.height / 2,
(int) ((shapeRect.width + distance) / 2 - leadLenght) + leadThickness / 2,
(int) shapeRect.height / 2);
if (shouldShadeLeads()) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(leadThickness - 2));
g2d.setColor(getLeadColor(componentState));
g2d.drawLine((int) (shapeRect.width - distance) / 2, (int) shapeRect.height / 2,
(int) ((shapeRect.width - distance) / 2 + leadLenght) - leadThickness / 2,
(int) shapeRect.height / 2);
g2d.drawLine((int) (shapeRect.width + distance) / 2, (int) shapeRect.height / 2,
(int) ((shapeRect.width + distance) / 2 - leadLenght) + leadThickness / 2,
(int) shapeRect.height / 2);
}
// Do not track the label because that area was already covered.
drawingObserver.stopTracking();
// Draw label.
g2d.setFont(LABEL_FONT);
g2d.setColor(componentState == ComponentState.SELECTED ? LABEL_COLOR_SELECTED : labelColor);
FontMetrics fontMetrics = g2d.getFontMetrics();
String label = display == Display.NAME ? getName() : getValue().toString();
// Adjust label angle if needed to make sure that it's readable.
if ((theta >= Math.PI / 2 && theta <= Math.PI)
|| (theta < -Math.PI / 2 && theta > -Math.PI)) {
g2d.rotate(Math.PI, shapeRect.width / 2, shapeRect.height / 2);
}
Rectangle2D textRect = fontMetrics.getStringBounds(label, g2d);
g2d.drawString(label, (int) (shapeRect.width - textRect.getWidth()) / 2,
(int) (shapeRect.height - textRect.getHeight()) / 2 + fontMetrics.getAscent());
}
protected void decorateComponentBody(Graphics2D g2d) {
// Do nothing.
}
protected boolean shouldShadeLeads() {
return true;
}
/**
* @return default component length.
*/
protected abstract Size getDefaultLength();
/**
* Returns default component width.
*
* @return
*/
protected abstract Size getDefaultWidth();
/**
* @return shape that represents component body. Shape should not be
* transformed and should be referenced to (0, 0).
*/
protected abstract Shape getBodyShape();
/**
* @return default lead thickness. Override this method to change it.
*/
protected Size getLeadThickness() {
return LEAD_THICKNESS;
}
/**
* @return default lead color. Override this method to change it.
*/
protected Color getLeadColor(ComponentState componentState) {
return componentState == ComponentState.SELECTED
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : LEAD_COLOR;
}
@Override
public int getControlPointCount() {
return points.length;
}
@Override
public Point getControlPoint(int index) {
return (Point) points[index];
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.ALWAYS;
}
@Override
public void setControlPoint(Point point, int index) {
points[index].setLocation(point);
}
@EditableProperty(name = "Color")
public Color getBodyColor() {
return bodyColor;
}
public void setBodyColor(Color bodyColor) {
this.bodyColor = bodyColor;
}
@EditableProperty(name = "Border")
public Color getBorderColor() {
return borderColor;
}
public void setBorderColor(Color borderColor) {
this.borderColor = borderColor;
}
@EditableProperty(name = "Length", defaultable = true)
public Size getLength() {
return length;
}
public void setLength(Size length) {
this.length = length;
}
@EditableProperty(name = "Width", defaultable = true)
public Size getWidth() {
return width;
}
public void setWidth(Size width) {
this.width = width;
}
@EditableProperty
public Display getDisplay() {
return display;
}
public void setDisplay(Display display) {
this.display = display;
}
}
@@ -0,0 +1,36 @@
package org.diylc.components;
import java.awt.Point;
public abstract class AbstractSinglePointComponent extends AbstractComponent<Void> {
private static final long serialVersionUID = 1L;
protected Point point = new Point(0, 0);
@Override
public int getControlPointCount() {
return 1;
}
@Override
public Point getControlPoint(int index) {
return point;
}
@Override
public void setControlPoint(Point point, int index) {
this.point.setLocation(point);
}
@Deprecated
@Override
public Void getValue() {
return null;
}
@Deprecated
@Override
public void setValue(Void value) {
}
}
@@ -0,0 +1,21 @@
package org.diylc.components;
import org.diylc.core.annotations.EditableProperty;
public abstract class AbstractTransparentComponent<T> extends AbstractComponent<T> {
private static final long serialVersionUID = 1L;
public static byte MAX_ALPHA = 127;
protected byte alpha = MAX_ALPHA;
@EditableProperty
public Byte getAlpha() {
return alpha;
}
public void setAlpha(Byte alpha) {
this.alpha = alpha;
}
}
@@ -0,0 +1,13 @@
package org.diylc.core;
/**
* Validator that allows all values.
*
* @author Branislav Stojkovic
*/
public class AllowAllValidator implements IPropertyValidator {
@Override
public void validate(Object value) throws ValidationException {
}
}
@@ -1,4 +1,4 @@
package org.diylc.model;
package org.diylc.core;
/**
* Enumerates all possible states that a component can be in.
@@ -0,0 +1,6 @@
package org.diylc.core;
public enum CreationMethod {
SINGLE_CLICK, POINT_BY_POINT;
}
+121
View File
@@ -0,0 +1,121 @@
package org.diylc.core;
import java.awt.Graphics2D;
import java.awt.Point;
import java.io.Serializable;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
/**
* Interface for component instance. Implementation classes of this interface
* will be instantiated by the application when component is added to the
* canvas. <br>
* <br>
* <b>Implementing classes should meet the following: </b>
* <ul>
* <li>Must have an empty constructor.</li>
* <li>Class should be annotated with {@link ComponentDescriptor}.</li>
* <li>Getters for properties editable by users should be annotated with
* {@link EditableProperty}.</li>
* <li>Component configuration should be stored int <code>public static</code>
* fields so they can be set through config file.</li>
* </ul>
*
* @author Branislav Stojkovic
*
* @param <T>
* type of component values, e.g. Resistance for resistors or String
* for transistors.
*/
public interface IDIYComponent<T> extends Serializable {
public static final int CHASSIS = 1;
public static final int BOARD = 2;
public static final int TRACE = 3;
public static final int COMPONENT = 4;
public static final int TEXT = 5;
/**
* @return component instance name.
*/
String getName();
/**
* Updates component instance name.
*
* @param name
*/
void setName(String name);
/**
* @return component value.
*/
T getValue();
/**
* Updates component value.
*
* @param value
*/
void setValue(T value);
/**
* @return number of control points for this component instance. May vary
* between two instances of the same type, e.g. DIL IC with 8 and 16
* pins will have 8 or 16 pins although they are of the same type.
*/
int getControlPointCount();
/**
* @param index
* @return control point at the specified index.
*/
Point getControlPoint(int index);
/**
* Updates the control point at the specified index.
*
* @param point
* @param index
*/
void setControlPoint(Point point, int index);
/**
* @param index
* @return true, if the specified control point may stick to control points
* of other components.
*/
boolean isControlPointSticky(int index);
/**
* @param index
* @return true, if the specified control point may overlap with other
* control points <b>of the same component</b>. The other control
* point must be able to overlap too.
*/
boolean canControlPointOverlap(int index);
VisibilityPolicy getControlPointVisibilityPolicy(int index);
/**
* Draws the component onto the {@link Graphics2D}.
*
* @param g2d
* @param componentState
* @param project
* @param drawingObserver
*/
void draw(Graphics2D g2d, ComponentState componentState, Project project,
IDrawingObserver drawingObserver);
/**
* Draws icon representation of the component. This should not depend on
* component state, i.e. it should be treated as a static method.
*
* @param g2d
* @param width
* @param height
*/
void drawIcon(Graphics2D g2d, int width, int height);
}
@@ -0,0 +1,15 @@
package org.diylc.core;
/**
* Interface for tracking component drawing process. Components may use it to
* stop or restart tracking. Anything drawn while tracking is stopped will not
* be added to the mouse hot-spot area.
*
* @author Branislav Stojkovic
*/
public interface IDrawingObserver {
void stopTracking();
void startTracking();
}
@@ -0,0 +1,16 @@
package org.diylc.core;
/**
* Interface for validating property value changes.
*
* @author Branislav Stojkovic
*/
public interface IPropertyValidator {
/**
* @param value
* @throws ValidationException
* if validation fails. Message will contain the reason.
*/
void validate(Object value) throws ValidationException;
}
+28
View File
@@ -0,0 +1,28 @@
package org.diylc.core;
/**
* Base interface for the main GUI component.
*
* @author Branislav Stojkovic
*/
public interface IView {
public static final int ERROR_MESSAGE = 0;
public static final int INFORMATION_MESSAGE = 1;
public static final int WARNING_MESSAGE = 2;
public static final int QUESTION_MESSAGE = 3;
public static final int PLAIN_MESSAGE = -1;
public static final int DEFAULT_OPTION = -1;
public static final int YES_NO_OPTION = 0;
public static final int YES_NO_CANCEL_OPTION = 1;
public static final int OK_CANCEL_OPTION = 2;
public static final int YES_OPTION = 0;
public static final int NO_OPTION = 1;
public static final int CANCEL_OPTION = 2;
public static final int OK_OPTION = 0;
void showMessage(String message, String title, int messageType);
int showConfirmDialog(String message, String title, int optionType, int messageType);
}
@@ -1,13 +1,15 @@
package org.diylc.model;
package org.diylc.core;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.diylc.model.annotations.EditableProperty;
import org.diylc.model.measures.Size;
import org.diylc.model.measures.SizeUnit;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.PositiveMeasureValidator;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
/**
* Entity class that defines a project. Contains project properties and a
@@ -23,34 +25,30 @@ public class Project implements Serializable {
public static String DEFAULT_TITLE = "New Project";
public static Size DEFAULT_WIDTH = new Size(29d, SizeUnit.cm);
public static Size DEFAULT_HEIGHT = new Size(21d, SizeUnit.cm);
public static Size DEFAULT_GRID_SPACING = new Size(0.1d, SizeUnit.in);
private String title;
private String author;
private String description;
private Size width;
private Size height;
private List<IComponentInstance> components;
private Size gridSpacing;
private List<IDIYComponent<?>> components;
private Set<Set<IDIYComponent<?>>> groups;
private Set<Integer> lockedLayers;
public Project() {
components = new ArrayList<IComponentInstance>();
components = new ArrayList<IDIYComponent<?>>();
groups = new HashSet<Set<IDIYComponent<?>>>();
lockedLayers = new HashSet<Integer>();
title = DEFAULT_TITLE;
author = System.getProperty("user.name");
width = DEFAULT_WIDTH;
height = DEFAULT_HEIGHT;
gridSpacing = DEFAULT_GRID_SPACING;
}
public Project(String title, String author, String description, Size width, Size height,
List<IComponentInstance> components) {
super();
this.title = title;
this.author = author;
this.description = description;
this.width = width;
this.height = height;
this.components = components;
}
@EditableProperty
@EditableProperty(defaultable = false)
public String getTitle() {
return title;
}
@@ -68,7 +66,7 @@ public class Project implements Serializable {
this.author = author;
}
@EditableProperty
@EditableProperty(defaultable = false)
public String getDescription() {
return description;
}
@@ -95,10 +93,37 @@ public class Project implements Serializable {
this.height = height;
}
public List<IComponentInstance> getComponents() {
@EditableProperty(name = "Grid spacing", validatorClass = SpacingValidator.class)
public Size getGridSpacing() {
return gridSpacing;
}
public void setGridSpacing(Size gridSpacing) {
this.gridSpacing = gridSpacing;
}
/**
* List of components sorted by z-order ascending.
*
* @return
*/
public List<IDIYComponent<?>> getComponents() {
return components;
}
/**
* Set of grouped components.
*
* @return
*/
public Set<Set<IDIYComponent<?>>> getGroups() {
return groups;
}
public Set<Integer> getLockedLayers() {
return lockedLayers;
}
@Override
public int hashCode() {
final int prime = 31;
@@ -154,11 +179,31 @@ public class Project implements Serializable {
return true;
}
@Override
public String toString() {
return title;
}
public static class SpacingValidator extends PositiveMeasureValidator {
@Override
public void validate(Object value) throws ValidationException {
super.validate(value);
Size size = (Size) value;
if (size.compareTo(new Size(1d, SizeUnit.mm)) < 0) {
throw new ValidationException("must be greater than 1mm");
}
if (size.compareTo(new Size(1d, SizeUnit.in)) > 0) {
throw new ValidationException("must be less than 1in");
}
}
}
// @Override
// public Project clone() throws CloneNotSupportedException {
// List<IComponentInstance> clonedComponents = new
// ArrayList<IComponentInstance>();
// for (IComponentInstance component : components) {
// List<IDIYComponent> clonedComponents = new
// ArrayList<IDIYComponent>();
// for (IDIYComponent component : components) {
// clonedComponents.add(component.clone());
// }
// Project project = new Project(title, author, description,
@@ -0,0 +1,11 @@
package org.diylc.core;
public class ValidationException extends Exception {
private static final long serialVersionUID = 1L;
public ValidationException(String message) {
super(message);
}
}
@@ -1,4 +1,4 @@
package org.diylc.model;
package org.diylc.core;
/**
* Enumerates control point visibility policies.
@@ -0,0 +1,62 @@
package org.diylc.core.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent;
/**
* Annotation for {@link IDIYComponent} implementation. Describes component
* properties.
*
* @author Branislav Stojkovic
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface ComponentDescriptor {
/**
* @return component type name.
*/
String name();
/**
* @return component type description.
*/
String description();
/**
* @return method that should be used to create a component. If
* <code>CreationMethod.POINT_BY_POINT</code> is used, user will
* have to select ending points before the component is created.
*/
CreationMethod creationMethod() default CreationMethod.SINGLE_CLICK;
/**
* @return component category, e.g. "Passive", "Semiconductors", etc.
*/
String category();
/**
* @return component author name.
*/
String author();
/**
* @return prefix that will be used to generate component instance names,
* e.g. "R" for resistors or "Q" for transistors.
*/
String instanceNamePrefix();
/**
* @return Z-order of the component.
*/
double zOrder();
/**
* @return when false, moving one control point will cause all the others to
* move together with it.
*/
boolean stretchable() default true;
}
@@ -1,8 +1,11 @@
package org.diylc.model.annotations;
package org.diylc.core.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.diylc.core.AllowAllValidator;
import org.diylc.core.IPropertyValidator;
/**
* Used to annotate editable component property. Editable property XYZ must have
* both getter and setter named <code>getXYZ</code> and <code>setXYZ</code>
@@ -16,16 +19,24 @@ public @interface EditableProperty {
/**
* Returns property name. If left blank property name will be extracted from
* the getter name, e.g. getter <code>getXYZ</code> will induce property
* name <code>XYZ</code>.
* name <code>XYZ</code>. <br>
* Default value is blank.
*
* @return
*/
String name() default "";
/**
* If true, application may set default value for this property.
* If true, application may set default value for this property. <br>
* Default value is true.
*
* @return
*/
boolean defaultable() default false;
boolean defaultable() default true;
/**
* Class of validator to use to
* @return
*/
Class<? extends IPropertyValidator> validatorClass() default AllowAllValidator.class;
}
@@ -0,0 +1,20 @@
package org.diylc.core.annotations;
import org.diylc.core.IPropertyValidator;
import org.diylc.core.ValidationException;
import org.diylc.core.measures.AbstractMeasure;
public class PositiveMeasureValidator implements IPropertyValidator {
@Override
public void validate(Object value) throws ValidationException {
if (value instanceof AbstractMeasure) {
AbstractMeasure measure = (AbstractMeasure) value;
if (measure.getValue() <= 0) {
throw new ValidationException("must be greater than zero.");
}
} else {
throw new ValidationException("wrong data type, measure expected.");
}
}
}
@@ -1,4 +1,4 @@
package org.diylc.model.measures;
package org.diylc.core.measures;
import java.io.Serializable;
import java.text.DecimalFormat;
@@ -8,7 +8,7 @@ public class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializ
private static final long serialVersionUID = 1L;
protected static final Format format = new DecimalFormat("#.00##");
protected static final Format format = new DecimalFormat("0.####");
protected Double value;
protected T unit;
@@ -37,6 +37,11 @@ public class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializ
public void setUnit(T multiplier) {
this.unit = multiplier;
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override
public int hashCode() {
@@ -0,0 +1,31 @@
package org.diylc.core.measures;
public class Capacitance extends AbstractMeasure<CapacitanceUnit> {
private static final long serialVersionUID = 1L;
public Capacitance() {
super();
// TODO Auto-generated constructor stub
}
public Capacitance(Double value, CapacitanceUnit unit) {
super(value, unit);
// TODO Auto-generated constructor stub
}
@Override
public Capacitance clone() throws CloneNotSupportedException {
return new Capacitance(value, unit);
}
public static Capacitance parseCapacitance(String value) {
for (CapacitanceUnit unit : CapacitanceUnit.values()) {
if (value.toLowerCase().endsWith(unit.toString().toLowerCase())) {
value = value.substring(0, value.length() - unit.toString().length() - 1).trim();
return new Capacitance(Double.parseDouble(value), unit);
}
}
throw new IllegalArgumentException("Could not parse capacitance: " + value);
}
}
@@ -1,4 +1,4 @@
package org.diylc.model.measures;
package org.diylc.core.measures;
public enum CapacitanceUnit implements Unit {
@@ -0,0 +1,31 @@
package org.diylc.core.measures;
public class Inductance extends AbstractMeasure<InductanceUnit> {
private static final long serialVersionUID = 1L;
public Inductance() {
super();
// TODO Auto-generated constructor stub
}
public Inductance(Double value, InductanceUnit unit) {
super(value, unit);
// TODO Auto-generated constructor stub
}
@Override
public Inductance clone() throws CloneNotSupportedException {
return new Inductance(value, unit);
}
public static Inductance parseCapacitance(String value) {
for (InductanceUnit unit : InductanceUnit.values()) {
if (value.toLowerCase().endsWith(unit.toString().toLowerCase())) {
value = value.substring(0, value.length() - unit.toString().length() - 1).trim();
return new Inductance(Double.parseDouble(value), unit);
}
}
throw new IllegalArgumentException("Could not parse inductance: " + value);
}
}
@@ -1,4 +1,4 @@
package org.diylc.model.measures;
package org.diylc.core.measures;
public enum InductanceUnit implements Unit {
@@ -0,0 +1,78 @@
package org.diylc.core.measures;
import java.awt.Color;
import org.diylc.common.ResistorColorCode;
public class Resistance extends AbstractMeasure<ResistanceUnit> {
private static final long serialVersionUID = 1L;
private static final Color[] COLOR_DIGITS = new Color[] { Color.black, Color.decode("#8B4513"),
Color.red, Color.orange, Color.yellow, Color.decode("#76EE00"), Color.blue,
Color.decode("#91219E"), Color.lightGray, Color.white };
private static final Color[] COLOR_MULTIPLIER = new Color[] { Color.lightGray.brighter(),
Color.decode("#FFB90F"), Color.black, Color.decode("#8B4513"), Color.red, Color.orange,
Color.yellow, Color.decode("#76EE00"), Color.blue };
public Resistance() {
super();
// TODO Auto-generated constructor stub
}
public Resistance(Double value, ResistanceUnit multiplier) {
super(value, multiplier);
// TODO Auto-generated constructor stub
}
@Override
public Resistance clone() throws CloneNotSupportedException {
return new Resistance(value, unit);
}
public Color[] getColorCode(ResistorColorCode resistorColorCode) {
Color[] bands;
double base = getValue() * getUnit().getFactor();
int multiplier = 0;
while (base > (resistorColorCode == ResistorColorCode._4_BAND ? 99 : 999)) {
multiplier += 1;
base /= 10;
}
while (base < (resistorColorCode == ResistorColorCode._4_BAND ? 10 : 100)) {
multiplier -= 1;
base *= 10;
}
if (multiplier > 6 || multiplier < -2) {
// Out of range.
return new Color[] {};
}
switch (resistorColorCode) {
case _4_BAND:
bands = new Color[3];
bands[0] = COLOR_DIGITS[(int) Math.round(base / 10)];
bands[1] = COLOR_DIGITS[(int) Math.round(base % 10)];
bands[2] = COLOR_MULTIPLIER[multiplier + 2];
break;
case _5_BAND:
bands = new Color[4];
bands[0] = COLOR_DIGITS[(int) Math.round(base / 100)];
bands[1] = COLOR_DIGITS[(int) Math.round(base / 10 % 10)];
bands[2] = COLOR_DIGITS[(int) Math.round(base % 10)];
bands[3] = COLOR_MULTIPLIER[multiplier + 2];
break;
default:
bands = new Color[] {};
}
return bands;
}
public static Resistance parseResistance(String value) {
for (ResistanceUnit unit : ResistanceUnit.values()) {
if (value.toLowerCase().endsWith(unit.toString().toLowerCase())) {
value = value.substring(0, value.length() - unit.toString().length() - 1).trim();
return new Resistance(Double.parseDouble(value), unit);
}
}
throw new IllegalArgumentException("Could not parse resistance: " + value);
}
}
@@ -1,4 +1,4 @@
package org.diylc.model.measures;
package org.diylc.core.measures;
public enum ResistanceUnit implements Unit {
@@ -0,0 +1,47 @@
package org.diylc.core.measures;
import org.diylc.utils.Constants;
public class Size extends AbstractMeasure<SizeUnit> implements Comparable<Size> {
private static final long serialVersionUID = 1L;
public Size() {
super();
// TODO Auto-generated constructor stub
}
public Size(Double value, SizeUnit unit) {
super(value, unit);
// TODO Auto-generated constructor stub
}
public int convertToPixels() {
// double factor = getUnit().getFactor() / SizeUnit.in.getFactor();
// int grids = (int) (factor * getValue() * Constants.GRIDS_PER_INCH);
// double remainder = (factor * getValue() * Constants.GRIDS_PER_INCH) - grids;
// return (int) Math.round(Constants.PIXELS_PER_INCH / Constants.GRIDS_PER_INCH
// * (grids + remainder));
return (int) (getValue() * getUnit().getFactor() / SizeUnit.in.getFactor() * Constants.PIXELS_PER_INCH);
}
@Override
public Size clone() throws CloneNotSupportedException {
return new Size(value, unit);
}
public static Size parseSize(String value) {
for (SizeUnit unit : SizeUnit.values()) {
if (value.toLowerCase().endsWith(unit.toString().toLowerCase())) {
value = value.substring(0, value.length() - unit.toString().length() - 1).trim();
return new Size(Double.parseDouble(value), unit);
}
}
throw new IllegalArgumentException("Could not parse size: " + value);
}
@Override
public int compareTo(Size o) {
return new Double(value * unit.getFactor()).compareTo(o.getValue() * o.getUnit().getFactor());
}
}
@@ -1,4 +1,4 @@
package org.diylc.model.measures;
package org.diylc.core.measures;
public enum SizeUnit implements Unit {
@@ -1,4 +1,4 @@
package org.diylc.model.measures;
package org.diylc.core.measures;
public interface Unit {
@@ -1,5 +1,10 @@
package org.diylc.images;
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;
@@ -14,14 +19,18 @@ public enum IconLoader {
"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"), Donate("donate.gif"), WindowColors(
"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"), ;
"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");
protected String name;
@@ -38,4 +47,14 @@ public enum IconLoader {
return null;
}
}
public Image getImage() {
BufferedImage img = null;
try {
img = ImageIO.read(getClass().getResourceAsStream(name));
} catch (IOException e) {
System.err.println("Couldn't find file: " + name);
}
return img;
}
}

Before

Width:  |  Height:  |  Size: 875 B

After

Width:  |  Height:  |  Size: 875 B

Before

Width:  |  Height:  |  Size: 729 B

After

Width:  |  Height:  |  Size: 729 B

Before

Width:  |  Height:  |  Size: 749 B

After

Width:  |  Height:  |  Size: 749 B

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 736 B

Before

Width:  |  Height:  |  Size: 707 B

After

Width:  |  Height:  |  Size: 707 B

Before

Width:  |  Height:  |  Size: 714 B

After

Width:  |  Height:  |  Size: 714 B

Before

Width:  |  Height:  |  Size: 993 B

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Before

Width:  |  Height:  |  Size: 863 B

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 850 B

Before

Width:  |  Height:  |  Size: 708 B

After

Width:  |  Height:  |  Size: 708 B

Before

Width:  |  Height:  |  Size: 960 B

After

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

Before

Width:  |  Height:  |  Size: 728 B

After

Width:  |  Height:  |  Size: 728 B

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 595 B

Before

Width:  |  Height:  |  Size: 781 B

After

Width:  |  Height:  |  Size: 781 B

Before

Width:  |  Height:  |  Size: 914 B

After

Width:  |  Height:  |  Size: 914 B

Before

Width:  |  Height:  |  Size: 876 B

After

Width:  |  Height:  |  Size: 876 B

Before

Width:  |  Height:  |  Size: 853 B

After

Width:  |  Height:  |  Size: 853 B

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Before

Width:  |  Height:  |  Size: 696 B

After

Width:  |  Height:  |  Size: 696 B

Before

Width:  |  Height:  |  Size: 597 B

After

Width:  |  Height:  |  Size: 597 B

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 845 B

Before

Width:  |  Height:  |  Size: 928 B

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Before

Width:  |  Height:  |  Size: 892 B

After

Width:  |  Height:  |  Size: 892 B

Before

Width:  |  Height:  |  Size: 751 B

After

Width:  |  Height:  |  Size: 751 B

Before

Width:  |  Height:  |  Size: 834 B

After

Width:  |  Height:  |  Size: 834 B

Before

Width:  |  Height:  |  Size: 857 B

After

Width:  |  Height:  |  Size: 857 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

Before

Width:  |  Height:  |  Size: 842 B

After

Width:  |  Height:  |  Size: 842 B

Before

Width:  |  Height:  |  Size: 910 B

After

Width:  |  Height:  |  Size: 910 B

Before

Width:  |  Height:  |  Size: 875 B

After

Width:  |  Height:  |  Size: 875 B

Before

Width:  |  Height:  |  Size: 694 B

After

Width:  |  Height:  |  Size: 694 B

Before

Width:  |  Height:  |  Size: 773 B

After

Width:  |  Height:  |  Size: 773 B

Some files were not shown because too many files have changed in this diff Show More